在 Laravel 5.8 / vuejs 2.6 应用程序中,我需要使用国家/地区列表,并使用内容创建文件 resources/js/helpers/countries.js :export const countriesList = [ { "Code": "AF", "Name": "Afghanistan" }, ... { "Code": "ZW", "Name": "Zimbabwe" }]在 vue 文件中我做了:<template> <div class="page-content col-md-offset-3"> countriesList:{{ countriesList }} </div></template><script> import {bus} from '../../../../app'; import appMixin from '../../../../appMixin'; import { getAdmindashApi, getUseAdmindashApi } from "./../../../../helpers/commonFuncs"; // resources/js/helpers/commonFuncs.js import { countriesList } from './../../../../../js/helpers/countries.js' // resources/js/helpers/countries.js export default { data: function () { return { ... countriesList : [] } }, name: 'PersonalDetails', }</script>但是 countryList 是空的,我不明白为什么?
1 回答
![?](http://img1.sycdn.imooc.com/545847f50001126402200220-100-100.jpg)
弑天下
TA贡献1818条经验 获得超8个赞
您将 data 中的值定义为空列表[]。
data: function () {
return {
...
countriesList : [] // this will make the array as empty
}
},
只需删除[],它就会像countriesList: countriesList.
data: function () {
return {
...
countriesList // => countriesList: countriesList
}
},
添加回答
举报
0/150
提交
取消