首页 > 其他分享 >vuecli之todo练习1静态资源html

vuecli之todo练习1静态资源html

时间:2022-11-10 10:33:57浏览次数:49  
标签:vuecli color todo li 1px html margin border

首先建立静态资源html

App。vue

<template>
    <div id="app">
      <div class="todo-container">
        <div class="todo-wrap">
          
          <MyHeader></MyHeader>

          <MyList ></MyList>
          
          <MyFooter></MyFooter>
        </div>
      </div>
    </div>
</template>

<script>
import MyFooter from './components/MyFooter.vue'
import MyHeader from './components/MyHeader.vue'
// import MyItem from './components/MyItem.vue' item为list的子组件
import MyList from './components/MyList.vue'
// import School from './components/School.vue'
export default {
  name: 'app',
  components: {
    MyHeader,
    MyFooter,
    
    // MyItem,
    MyList
    // School
  }
}
</script>

<style>
  /*base*/
body {
  background: #fff;
}

.btn {
  display: inline-block;
  padding: 4px 12px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.btn-danger {
  color: #fff;
  background-color: #da4f49;
  border: 1px solid #bd362f;
}

.btn-edit {
  color: #fff;
  background-color: lightgreen;
  border: 1px solid green;
  margin-right: 5px;
}

.btn-danger:hover {
  color: #fff;
  background-color: #bd362f;
}

.btn-edit:hover {
  color: #fff;
  background-color: green;
}

.btn:focus {
  outline: none;
}

.todo-container {
  width: 600px;
  margin: 0 auto;
}
.todo-container .todo-wrap {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}
</style>

Myheader

<template>
     <div class="todo-header">
        <input type="text" placeholder="请输入你的任务名称,按回车键确认" />
     </div>
</template>

<script>
export default {
    name:"MyHeader"
}
</script>

<style>
    /*header*/
    .todo-header input {
    width: 560px;
    height: 28px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 7px;
    }

    .todo-header input:focus {
    outline: none;
    border-color: rgba(82, 168, 236, 0.8);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
    }
</style>

MyFooter

<template>
        <div class="todo-footer" >
            <label>
            <input type="checkbox" />
            </label>
            <span>
            <span>已完成???</span> / 全部???
            </span>
            <button class="btn btn-danger">清除已完成任务</button>
        </div>
</template>

<script>
export default {
    name:"MyFooter",

}
</script>

<style>
    /*footer*/
    .todo-footer {
    height: 40px;
    line-height: 40px;
    padding-left: 6px;
    margin-top: 5px;
    }

    .todo-footer label {
    display: inline-block;
    margin-right: 20px;
    cursor: pointer;
    }

    .todo-footer label input {
    position: relative;
    top: -1px;
    vertical-align: middle;
    margin-right: 5px;
    }

    .todo-footer button {
    float: right;
    margin-top: 5px;
    }
</style>

MyList

<template>
      <ul class="todo-main">
        <MyItem v-for="(todoObj) in todos" :key="todoObj.id" :todo="todoObj"></MyItem>
    </ul>
</template>

<script>
import  MyItem  from "./MyItem";
export default {
    name:"MyList",
    components:{MyItem},
    data() {
        return {
            todos:[
                {id:"001",title:"吃饭",done:true},
                {id:"002",title:"抽烟",done:false},
                {id:"003",title:"烫头",done:true},
            ]
        }
    },
}
</script>

<style>
    /*main*/
    .todo-main {
    margin-left: 0px;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 0px;
    }

    .todo-empty {
    height: 40px;
    line-height: 40px;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding-left: 5px;
    margin-top: 10px;
    }
</style>

MyItem

<template>
      <transition>
        <li>
            <label>
              <input type="checkbox" :checked="todo.done"/>
              <span>{{todo.title}}</span>
              <!-- <input type="text"> -->
            </label>
            <button class="btn btn-danger" >删除</button>
            <!-- <button class="btn btn-edit">编辑</button> -->
        </li>
    </transition>
</template>

<script>
export default {
    name:"MyItem",
    //声明接受tudu对象
    props:['todo'],
    // mounted() {
    //   console.log(this.todo)
    // },

}
</script>

<style>
    /*item*/
 li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}

li:hover{
  background-color: #ddd;
}

li:hover button{
  display: block;
}

.todo-enter-active{
  animation: todo 0.5s linear;
}

.todo-leave-active{
  animation: todo 0.5s linear reverse;
}

@keyframes todo {
  from{
    transform: translateX(100%);
  }
  to{
    transform: translateX(0px);
  }
} 
</style>

 

标签:vuecli,color,todo,li,1px,html,margin,border
From: https://www.cnblogs.com/xiaobaizitaibai/p/16876269.html

相关文章

  • 一文详解DevExpress的HTML & CSS模板如何实现集合渲染
    DevExpressWinForm拥有180+组件和UI库,能为WindowsForms平台创建具有影响力的业务解决方案。DevExpressWinForms能完美构建流畅、美观且易于使用的应用程序,无论是Office......
  • 爱心代码Html
    1<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">2<HTML>3<HEAD>4<TITLE>Love</TITLE>5<METANAME="Generator"CONTENT="Ed......
  • 爱心代码 HTML/CSS3
     <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><HTML><HEAD><TITLE>Love</TITLE><METANAME="Generator"CONTENT="EditPlus"><METANAME="Author"......
  • 一些有用的 HTML 字符实体 < >"&
    ResultEntityName &nbsp;<<>>&&amp;""'&apos;¢&cent;£&pound;¥&yen;€&euro;©&copy;®&reg;     ......
  • HTML----常用标记(文本、文字、超链接与锚点连接)
    1.标记的分类单标记:只有一个标记既是开始,也是结束,如:图片、视频双标记:又开始有结束,成对出现的,主要作用就是描述标记的内容,如:div2.文本、文字<font></font......
  • HTML----介绍
    HTML开发工具:vscode推荐书籍:HTML+css入门到精通1.HTML介绍超文本标记语言:浏览器只能看懂HTML、css、js,所以web开发中HTML是最基本的一门语言,普通的文本扩展上音频、视......
  • html中使用mqtt
    MQTT.js 是一个开源项目,支持nodejs和Browserjs,这里对比一下nodejs和Browserjs的用法:注:nodejs是运行在webserver的js,Browserjs意思是运行在浏览器上的js,也就是H......
  • java中将word转换为html导入到ckeditor编辑器中(解决图片问题,样式,非常完美)
    ​ 自动导入Word图片,或者粘贴Word内容时自动上传所有的图片,并且最终保留Word样式,这应该是Web编辑器里面最基本的一个需求功能了。一般情况下我们将Word内容粘贴到Web编辑......
  • HTML5+CSS3
    一、HTML基础(一)HTML1、常用浏览器​内核浏览器备注IETridentIE,猎豹,360,百度FireFoxGecko火狐SafariWebkit苹果chrome/operaBlinkchrome/......
  • Razor视图cshtml做到运行时编译【提高开发效率】
    当你的.NET开发工具升级到.NETCore版本以上,就会发现有时候无法将视图界面做的修改可以直接保存后刷新输出,一般都需要重新热重载或重新编译,这样会导致开发效率过慢的行为,开......