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