我试图在挂载组件之后调用一个方法,但似乎在将数据提供给组件之前就触发了该方法。
我收到以下错误:
[Vue warn]: Error in mounted hook: "ReferenceError: url_refresh is not defined"我的组件如下所示:
export default {
props: {
columns: Array,
url_base: String,
url_refresh: String,
},
methods: {
refresh() {
axios.get(url_refresh)
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
}
},
computed: {
// URL para Editar
url_edit: function () {
return this.url_edit+'/edit/'+item.id
}
},
mounted() {
this.refresh()
},
}我这样称呼它:
<nexdatatable
:columns="['Nome','Tipo de Cliente', 'Documento', 'Filiais']"
:url_refresh="`{{route('clients.refresh_table', ['tenant_id'=>auth()->user()->tenant_id])}}`"
:url_base="`{{route('clients.index')}}`"
ref="nexdatatable"></nexdatatable>
</div>发布于 2020-10-03 03:15:40
必须使用this引用所有props或data,因此:
axios.get(this.url_refresh)....https://stackoverflow.com/questions/64177016
复制相似问题