折腾:
【未解决】vuejs加上属性变量值
期间,去试试代码:
data: { nxmleVisibility: 'hidden' },
结果报错:
`data` property in component must be a function eslintvue/no-shared-component-data
export default { name: 'Dashboard', // nxmleVisibility: 'hidden', timer: '', data: { nxmleVisibility: 'hidden' }, computed: { ...mapGetters([ 'name' // 'nxmleVisibility' ]) },
问题依旧。
vuejs data property in component must be a function
改为
export default { name: 'Dashboard', // nxmleVisibility: 'hidden', timer: '', data: () => { return { nxmleVisibility: 'hidden' } }, computed: { ...mapGetters([ 'name' // 'nxmleVisibility' ]) }, created() { // this.timer = setInterval(this.updateSwitchStatus, 1000) },
至少没有报错。
【总结】
之前用:
data: { nxmleVisibility: 'hidden' },
报错:
`data` property in component must be a function
改为:
data: () => { return { nxmleVisibility: 'hidden' } },
即可。
转载请注明:在路上 » 【已解决】vuejs中加上data中的变量但报错:data property in component must be a function