首页 / 浏览问题 / 组件GIS / 问题详情
搜索enter后引用的js报错
1EXP 2020年07月24日

使用产品:Vue-iClient-MapboxGL

操作系统:win10 x64

问题详情:引用sm-search组件,输入1,按“enter”后,前端控制台报错 this.$message.destroy is not a function

如下:

vue.runtime.esm.js:1888 TypeError: this.$message.destroy is not a function
    at VueComponent.clearResult (iclient-mapboxgl-vue.js:84837)
    at VueComponent.search (iclient-mapboxgl-vue.js:84863)
    at VueComponent.searchButtonClicked (iclient-mapboxgl-vue.js:84860)
    at invokeWithErrorHandling (vue.runtime.esm.js:1854)
    at VueComponent.invoker (vue.runtime.esm.js:2179)
    at invokeWithErrorHandling (vue.runtime.esm.js:1854)
    at VueComponent.Vue.$emit (vue.runtime.esm.js:3882)
    at VueComponent.handleKeyDown (Input.js:182)
    at invokeWithErrorHandling (vue.runtime.esm.js:1854)
    at HTMLInputElement.invoker (vue.runtime.esm.js:2179)

前端source指向为:

iclient-mapboxgl-vue.js:

clearResult: function clearResult(isClear) {
      this.$message.destroy();

      ....

}

vue 代码如下:

<sm-search
  position="top-left"
  :layer-names="['水站列表']"
  :address-match="addressMatch"
  :rest-map="restMap"
  :online-local-search="onlineLocalSearch"
/>

data(){
   culsterLayerData: {
        type: "FeatureCollection",
        features: []
      },
      pointList: [],
      restMap: [
        {
          url: host + "/iserver/services/map-world/rest/maps/World",
          layerName: "Capitals@World.1"
        }
      ],
      addressMatch: [
        {
          url:
            host + "/iserver/services/addressmatch-Address/restjsr/v1/address"
        }
      ],
      onlineLocalSearch: {
        enable: true,
        city: "北京市"
      }
}

1个回答

您好,您可以     更具范例https://iclient.supermap.io/examples/component/editor.html#components_search_vue先改为官网上的示例服务进行查询,是否正常,如果是正常的,请检查您的代码和服务

3,357EXP 2020年07月24日

您好,根据范例,我发现我并不是很清楚Supermap的来源:

以下是报错信息

[Vue warn]: Error in data(): "TypeError: Cannot read property 'commontypes' of undefined"

found in

---> <Index> at src/views/zuihou/visualization/map/Index.vue
       <AppMain> at src/layout/components/AppMain.vue
         <Layout> at src/layout/index.vue
           <App> at src/App.vue
             <Root>

以下是代码(导入部分):

// import SuperMap from "leaflet";
import SuperMap from "@supermap/vue-iclient-mapboxgl";

import "@/../static/Supermap/mapbox-gl-enhance.js";

// import SuperMap from "@/../static/Supermap/include-mapboxgl" 

以下是data部分

 culsterLayerData: {
        type: "FeatureCollection",
        features: []
      },
      pointList: [],
      restMap: [
        new SuperMap.Components.commontypes.RestMapParameter({
          url: host + "/iserver/services/map-world/rest/maps/World",
          layerName: "Capitals@World.1"
        })
      ],
      addressMatch: [
        new SuperMap.Components.commontypes.AddressMatchParameter({
          url:
            host + "/iserver/services/addressmatch-Address/restjsr/v1/address"
        })
      ],
      onlineLocalSearch: {
        enable: true,
        city: "北京市"
      }

注,若是去掉导入部分导入的supermap,编辑器会报错:SuperMap is not defind。页面报错同“报错信息”。感觉是没有导入supermap

...