1. vue读取本地json文件显示到页面上
<template>
<el-option v-for="item in provinces111" :key="item.code" :label="item.name" :value="item.code">
</template>
<script>
    	import provinceCity from '../../static/table.json'
    	export default {
  
    name: 'provinceCity',
     data() {
        return {  provinces:[ ],
    	}
    	}
    	created() {
      this.provinces111 = provinceCity.provinces;
      }
      //JSON文件
      {
  "provinces":[
    {"name":"北海道","level":"1","code":"010006","cities":[
      {"name":"札幌市","level":"2","code":"011002"},
      {"name":"函館市","level":"2","code":"012025"},
      {"name":"小樽市","level":"2","code":"012033"}
    ]},
  ]
}

Logo

前往低代码交流专区

更多推荐