<template>
<div class="container"></div>
</template>
<script>
import ThemePicker from '@/components/ThemePicker'
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
import encryptionMd5 from '@/js/mixins/encryption-md5'
export default {
name: 'TableEdit',
data () {
const lang = localStorage.getItem('user-language') || 'zh-cn'
return {
tableEditShow: false, // 是否显示table字段编辑框
firstName: 'hmk',
lang: lang
}
},
components: {
ThemePicker
},
mixins: [encryptionMd5],
filters: {
addNumber (value, param) {
let turnValue = value + param
return turnValue
},
},
directives: {
// 自定义指令
localFocus: {
inserted: function (el, binding, vNode) {
el.getElementsByTagName('input')[0].focus()
}
}
},
props: {
tableLabel: {
type: Array
}
},
computed: {
// computed写法一
checkLists: function () {
let that = this
let value = []
that.tableLabel.forEach((item) => {
value.push(item.label)
})
return value
},
// computed写法二
checkedLength (count) {
return count++
},
// 使用对象展开运算符将此对象混入到外部对象中
// mapState、mapGetters辅助函数
...mapState({
vuexCount: 'count'
}),
...mapGetters({
doneTodo: 'doneTodos',
})
},
watch: {
'tableLabel': {
// 深度监听子组件数组
handler: function (newValue, oldValue) {
// console.log('子组件改变tableLabel的值', newValue)
},
deep: true
},
// 普通属性监听
firstName: function (oldValue, newValue) {
console.log(oldValue, newValue)
}
},
methods: {
editMethod () {
let that = this
that.tableEditShow = true
},
// mapMutations、mapActions辅助函数
...mapMutations({
vuexIncrement: 'increment'
}),
...mapActions({
vuexActionIncrement: 'actionIncrement'
})
},
created () {
// dom还没开始渲染
},
mounted () {
// dom未完全渲染完成
}
}
</script>
<style scoped>
@media (max-width: 768px) {
.header {
}
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
← 6.上传文件