The introduction of custom js file js file in vue

Custom js

var provinces=[]
export default provinces

vue page js introduced

import riskLeft from "./index.js";
export default riskLeft;

RiskLeft introduced into custom js (BACKGROUND: .vue html files and separate js)

import provinces from './province-data'
export default {
 data() {
   return {
     provinces: []
   }
 },
 created() {
   this.provinces = provinces
 }
}

Html page within vue variables can be used directly

<el-option v-for="p in provinces" :label="p" :value="p" :key="p.id"></el-option>

Guess you like

Origin www.cnblogs.com/wwj007/p/11358044.html