Skip to content

Commit

Permalink
第一次上传
Browse files Browse the repository at this point in the history
Signed-off-by: laoyang <[email protected]>
  • Loading branch information
lanhaner committed Mar 10, 2021
0 parents commit 0249ec4
Show file tree
Hide file tree
Showing 21 changed files with 12,039 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# todolist

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
11,499 changes: 11,499 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "todolist",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"sass": "^1.26.5",
"sass-loader": "^8.0.2"
}
}
Binary file added public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
7 changes: 7 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<router-view/>
</template>

<style lang="scss">
</style>
Binary file added src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions src/components/child/Child.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div>
This is Child
{{msg}}
<button @click="send">传值给父组件</button>
</div>
</template>

<script>
import {defineComponent,ref,onMounted} from 'vue'
export default defineComponent({
name:'Child',
props:{
msg:{
type:String
}
},
setup(props,ctx){
console.log(props.msg)
let childMsg = ref('这是子组件的数值')
let send = ()=>{
ctx.emit('childSend',childMsg.value)
}
onMounted(()=>{
ctx.emit('childSend',{
value1:childMsg.value,
value2:childMsg.value
})
})
return {
childMsg,
send
}
}
})
</script>

<style>
</style>
55 changes: 55 additions & 0 deletions src/components/navFooter/NavFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<div class="container">
<div>
已完成{{isCompelet}} / 全部{{list.length}}
</div>
<div v-if="isCompelet > 0" class="btn">
<button @click="clear">
清除已完成
</button>
</div>
</div>
</template>

<script>
import {defineComponent,ref,computed} from 'vue'
export default defineComponent({
name:'NavFooter',
props:{
list:{
type:Array,
required:true
}
},
setup(props,ctx){
let isCompelet = computed(()=>{
let arr = props.list.filter(item=>{
return item.complete
})
return arr.length
})
let clear = ()=>{
console.log('clear')
let arr = props.list.filter(item=>{
return item.complete == false
})
ctx.emit('clear',arr)
}
return{
isCompelet,
clear
}
}
})
</script>

<style scoped lang="scss">
.container{
display: flex;
align-items: center;
.btn{
margin-left:10px;
}
}
</style>
30 changes: 30 additions & 0 deletions src/components/navHeader/NavHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<div>
<input placeholder="请输入名称" v-model="value" @keydown.enter="enter"/>
</div>
</template>

<script>
import {defineComponent,ref} from 'vue'
export default defineComponent({
name:'NavHeader',
setup(props,ctx){
let value = ref('')
let enter = () =>{
// console.log(value.value)
ctx.emit('add',value.value)
value.value=''
}
return {
value,
enter
}
}
})
</script>

<style scoped lang="scss">
input{
margin-bottom:10px;
}
</style>
68 changes: 68 additions & 0 deletions src/components/navMain/NavMain.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div>
<div v-if="list.length>0">
<div v-for="(item,index) in list" :key="index">
<div class="item">
<input type="checkbox" v-model="item.complete">
{{item.title}}
<button @click="del(item,index)">删除</button>
</div>
</div>
</div>
<div v-else>
没有任务
</div>
</div>
</template>

<script>
import {
defineComponent,
ref
} from 'vue'
export default defineComponent({
name: 'NavMain',
props: {
list: {
type: Array,
required: true
}
},
emits: ['delTodo'],
setup(props, ctx) {
let del = (item, index) => {
// console.log(item,index)
ctx.emit('delTodo', index)
}
return {
del
}
}
})
</script>

<style scoped lang="scss">
.item {
height: 35px;
line-height: 35px;
width: 160px;
cursor: pointer;
position: relative;
button {
position: absolute;
right: 20px;
top: 6px;
display: none;
z-index: 99
}
&:hover {
background: #CCC;
button {
display: block;
}
}
}
</style>
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

createApp(App).use(store).use(router).mount('#app')
35 changes: 35 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/Start',
name: 'Start',
component: () => import('../views/Start.vue')
},
{
path: '/Detail',
name: 'Detail',
component: () => import('../views/Detail.vue')
},
{
path: '/About',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
}
]

const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})

export default router
43 changes: 43 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { createStore } from 'vuex'

export default createStore({
//定义所需要的状态
state: {
list : [
{
title:'吃饭',
complete:false
},
{
title:'睡觉',
complete:false
},
{
title:'打豆豆',
complete:false
}
]
},
//同步修改state,全是方法
mutations: {
//添加任务
addTodo(state,payload){
state.list.push(payload)
},
//删除任务
delTodo(state,payload){
state.list.splice(payload,1)
},
//删除已完成
clear(state,payload){
state.list = payload
}
},
//异步提交mutation
actions: {

},
//模块化
modules: {
}
})
Loading

0 comments on commit 0249ec4

Please sign in to comment.