uni-app中调用js里的数组


1.创建一个.js文件

global-roamings.js

export const params = { globalRoaming:[ { label:"中国", value:"86" }, { label:"阿富汗", value:"93" } ] }

2.页面中调用

login1.vue

<template>

<view class="cu-capsule radius">
<view class="cu-tag line-blue">
{{index>-1?picker[index].label:'中国大陆'}}
</view>
<view class='cu-tag bg-blue'>
<picker class="pickerList" range-key="label" @change="PickerChange" :value="index" :range="picker">
<view class="picker">
{{index>-1?picker[index].value:'+86'}}
</view>
</picker>
</view>

</template>

<script>
import {params} from "../components/global-roaming.js"
export default {
data() {
return {
mobile: '',
loginByPhone:'',
userInfo: {},
index: -1,
picker: [],
};
},
onShow() {
// console.log(JSON.stringify(params) )
this.picker = params.globalRoaming;
}

</script>

3.这样就完成了

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM