【发布时间】:2020-07-29 07:58:59
【问题描述】:
不确定为什么mounted没有触发其中的任何功能。页面加载时显示'ss'测试也无法打印出来。
export default {
name: 'loads',
components: {
Overlay,
},
data() {
return {
subscribed: true,
};
},
computed: {
filteredLocation() {
return this.$store.getters['location/filterLocation'](this.searchTerm);
},
},
methods: {
checkSubscriptionValidity() {
this.$store.dispatch('user/checkTrial').then((res) => {
this.subscribed = res.data;
});
},
},
mounted() {
console.log('ss');
this.checkSubscriptionValidity();
},
};
还有其他原因会导致此挂载未触发问题吗?
【问题讨论】:
-
没有错误?你能给我们看更多的代码吗
-
@Ifaruki 是的,没有错误。但未触发已安装。我已经编辑了代码并添加了整个脚本
-
我猜这是一个组件。那么你在哪里导入组件呢?
-
尝试 created() 钩子。如果它没有被调用,那么看看你在哪里渲染这个组件。
-
@Ifaruki,它是从 App.vue 路由的父组件。其他 Vue 文件路由在mounted() 中运行良好。只是这个文件挂载的钩子没有被触发
标签: javascript vue.js vuejs2