在Leaflet和Vue.js中创建的Select中,在函数事件(onChange)中调用函数 [英] Call function in function event (onChange), from Select created in Leaflet and Vue.js

查看:100
本文介绍了在Leaflet和Vue.js中创建的Select中,在函数事件(onChange)中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Vue.js和Leaflet中制作一个应用程序. 在此应用中,我使用L.DomUtil创建了一个Select in传单

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()不是函数"

But it not working, the error is "this.firstFunction() is not a function"

我试图放

   .../
     var _self = this
     _self.firstFunction()
    ../

但是还是不管用.

我该怎么办?谢谢.

推荐答案

您应该使用箭头函数()=>{...}来访问组件实例this,如下所示:

You should use arrow function ()=>{...} to get access to the component instance this as follows :

      secondFunction() {
          this.select.on('change', (e)=>{
            this.firstFunction()
              }
        }

这篇关于在Leaflet和Vue.js中创建的Select中,在函数事件(onChange)中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆