每写一个openlayers官网示例都要在我的项目中注册一个组件并引入,操作重复且繁琐,于是找了个偷懒的方法。如果有跟我起一样架子的小伙伴可以c一下~
每次增加一个组件List.vue中就需要进行这么几步操作
1、import 组件名 from xxx
2、components里面注册组件名
3、修改mapviewCom的值为最新组件名
4、list数组中添加一个对象text和name都为组件名
<script>
import FirstMap from "./components/FirstMap.vue";
import VectorTiles from "./components/VectorTiles.vue";
// components-import-placeholder
export default {
name: "",
components: {
FirstMap,
VectorTiles,
// components-object-placeholder
},
data() {
return {
mapviewCom: "VectorTiles",
list: [
{
name: "FirstMap",
text: "加载第一个地图",
},
{
name: "VectorTiles",
text: "加载第二个地图",
},
// list-placeholder
],
};
},
computed: {},
created() {},
methods: {
setMapView(item) {
this.mapviewCom = item.name;