Call function in function event (onChange), from Select created in Leaflet and Vue.js(函数事件(onChange)中的调用函数,来自在 Leaflet 和 Vue.js 中创建的 Select)
问题描述
我正在用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:函数事件(onChange)中的调用函数,来自在 Leaflet 和 Vue.js 中创建的 Select
基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
