Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Vue从jQuery onChange更新数据值_Javascript_Jquery_Ecmascript 6_Vuejs2 - Fatal编程技术网

Javascript 使用Vue从jQuery onChange更新数据值

Javascript 使用Vue从jQuery onChange更新数据值,javascript,jquery,ecmascript-6,vuejs2,Javascript,Jquery,Ecmascript 6,Vuejs2,我在Vue.js 2中使用引导日期选择器。引导日期选择器不会更新 但是如果我使用以下脚本,我无法访问要使用的范围this loadFormProps() { // init other stuff $('#founding_date').change(function() { this.founding_date = $(this).val(); }); } 模式如下: data() { return { founding_date: '01 - 01 - 2017', }

我在Vue.js 2中使用引导日期选择器。引导日期选择器不会更新

但是如果我使用以下脚本,我无法访问要使用的范围
this

loadFormProps() {
// init other stuff
$('#founding_date').change(function() {
  this.founding_date = $(this).val();
});
}
模式如下:

data() {
  return {
    founding_date: '01 - 01 - 2017',
  }
};

这方面的最佳解决方案是什么,因为我无法使
vm.$data
工作,并且我无法在函数中访问
this

您必须在
onchange
JS块之前将
this
保存在其他
var
中:

loadFormProps() {
// init other stuff
var that = this  
$('#founding_date').change(function() {
  that.founding_date = $(this).val();
});
}

change
回调函数中有两个
this
。此无法访问哪个
?控制台错误消息是什么?第一个
这个
应该指什么?有那么简单吗?谢谢你,先生!