gpt4 book ai didi

javascript - 导入的国家/地区列表为空

转载 作者:行者123 更新时间:2023-12-02 22:46:58 25 4
gpt4 key购买 nike

在 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>

但是国家列表是空的,我不明白为什么?

最佳答案

您将数据中的值定义为空列表[]

  data: function () {
return {
...
countriesList : [] // this will make the array as empty
}
},

只需删除[],它就会像countriesList:countriesList

  data: function () {
return {
...
countriesList // => countriesList: countriesList
}
},

关于javascript - 导入的国家/地区列表为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58355093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com