vuejs data可以是对象类型么
答案:2 悬赏:60 手机版
解决时间 2021-01-30 09:38
- 提问者网友:太高姿态
- 2021-01-29 08:48
vuejs data可以是对象类型么
最佳答案
- 五星知识达人网友:几近狂妄
- 2021-01-29 09:27
在一个普通的 Vue app 中,data 是一个对象: new Vue( { data : { title : 'abc' }} ); 在 Vue 的 Component 中,data 要写成一个 function,并返回对象: Vue.component( 'component-name', Vue.extend( { data : function() { return { title
全部回答
- 1楼网友:鱼芗
- 2021-01-29 09:54
vue.js把表单提交到data里:
axios({
url: '/user',
method: 'post',
data: {
firstname: 'fred',
lastname: 'flintstone'
},
transformrequest: [function (data) {
// do whatever you want to transform the data
let ret = ''
for (let it in data) {
ret += encodeuricomponent(it) + '=' + encodeuricomponent(data[it]) + '&'
}
return ret
}],
headers: {
'content-type': 'application/x-www-form-urlencoded'
}
})
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯