【发布时间】:2019-01-03 22:00:38
【问题描述】:
根据官方帮助(https://vuejs.org/v2/guide/components-dynamic-async.html),我已经为动态组件做了如下代码。
很容易将 props 传递给函数 resolve()。
但问题是,如何在 'resolve' 函数之前传递 taskId - 需要 VAR 而不是固定值 '1341'?
非常感谢!
Vue.component('task-name', function(resolve, reject){
// var instead '1341'?
axios.post("http://my-cite.com/taskname", {taskId: '1341'}).then(function (response){
resolve({
props: ['taskId'],
data: function(){
return {
response: response
}
},
template: '<div>I am async! And the response is: {{response}}</div>'
})
})
})
【问题讨论】:
-
你要传递给组件的值是从哪里来的?
标签: dynamic vue.js components