vue 路由器 $this 未定义
vue router $this not defined
我在 component/vue 之一中使用 vue-router,我尝试在加载特定组件时从数据库加载历史事务:
<script>
import store from '../store'
export default {
data() {
return {
histories: []
}
},
route: {
activate() {
$this.getHistories()
}
},
methods: {
getHistories() {
$this.histories = store.getHistories()
}
}
}
</script>
我遇到了这 2 个错误:
build.js:12642 [vue-router] Uncaught error during transition:
build.js:28551 Uncaught ReferenceError: $this is not defined
$this
不存在,需要使用this
:
export default {
data() {
return {
histories: []
}
},
route: {
activate() {
this.getHistories()
}
},
methods: {
getHistories() {
this.histories = store.getHistories()
}
}
}
我在 component/vue 之一中使用 vue-router,我尝试在加载特定组件时从数据库加载历史事务:
<script>
import store from '../store'
export default {
data() {
return {
histories: []
}
},
route: {
activate() {
$this.getHistories()
}
},
methods: {
getHistories() {
$this.histories = store.getHistories()
}
}
}
</script>
我遇到了这 2 个错误:
build.js:12642 [vue-router] Uncaught error during transition:
build.js:28551 Uncaught ReferenceError: $this is not defined
$this
不存在,需要使用this
:
export default {
data() {
return {
histories: []
}
},
route: {
activate() {
this.getHistories()
}
},
methods: {
getHistories() {
this.histories = store.getHistories()
}
}
}