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


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01