我正在用 Vue.js 和 Leaflet 制作一个应用程序.在这个应用程序中,我在使用 L.DomUtil 创建的传单中选择了一个
I am making a app in Vue.js and Leaflet. In this app, I have a Select in leaflet created with L.DomUtil
this.select = L.DomUtil.create('select','leaflet-countryselect',this.div);
我没有找到在这个选择"中放置v-on:change"的方法,所以,我必须在 Vue.js 的函数方法中调用一个事件函数.
I do not find the way for put 'v-on:change' in this 'Select', so, I have to call a event function, inside to a Function Method in Vue.js.
methods: {
firstFunction{
},
secondFunction() {
this.select.on('change', function(e){
this.firstFunction()
}
}
}
但它不起作用,错误是this.firstFunction() is not a function"
But it not working, the error is "this.firstFunction() is not a function"
我试着放了
.../
var _self = this
_self.firstFunction()
../
但无论如何都不起作用.
But not working, anyway.
我该怎么做?谢谢.
你应该使用箭头函数 ()=>{...} 来访问组件实例 this如下:
You should use arrow function ()=>{...} to get access to the component instance this as follows :
secondFunction() {
this.select.on('change', (e)=>{
this.firstFunction()
}
}
这篇关于函数事件(onChange)中的调用函数,来自在 Leaflet 和 Vue.js 中创建的 Select的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)
检测 FLASH 插件崩溃Detect FLASH plugin crashes(检测 FLASH 插件崩溃)