vue使用高德地图信息窗体里面的给点击事件

vue-amap中自定义窗体添加点击事件

最近做vue项目时候用到了vue-amap,但是在自定义窗体的时候碰到了问题,里面的点击事件怎么都不生效,看了官方文档说的是

template 模板渲染
支持传入 Vue 模板,支持 Vue 机制的事件绑定和状态访问。
当同时设置 content 和 template 时,优先 content。
v0.4.0 开始支持

意思就是说要使用template才能添加点击事件,但是换成template又出现报错

You are using the runtime-only build of Vue where the 
template compiler is not available. Either pre-compile 
the templates into render functions, or use the 
compiler-included build.

意思就是:template 模板渲染 支持传入 Vue 模板,支持 Vue 机制的事件绑定和状态访问。当同时设置 content 和 template 时,优先 content。v0.4.0 开始支持。


又各种找资料找文档,发现vue-amap的文档太少了,最后在一个小网站找到了解决方法,


配置项目,在项目的根目录下建立一个 vue.config.js的文件
代码如下:

    module.exports = {
    configureWebpack: {
        resolve: {
            alias: {
                'vue$': 'vue/dist/vue.esm.js'
            }
        }
    }
 }

然后,然后就好了,发个帖子自己记录一下,也是为后面再用的人少踩点坑!

Logo

前往低代码交流专区

更多推荐