Javascript 捕获子组件触发的事件后未呈现Vuejs 2 v-if指令

Javascript 捕获子组件触发的事件后未呈现Vuejs 2 v-if指令,javascript,laravel-5.3,vuejs2,vue.js,Javascript,Laravel 5.3,Vuejs2,Vue.js,我在使用Vuejs2.0和laravel 5.3。我从一个子组件(typeahead组件)发出一个自定义事件,并使用v-on指令捕获该事件 以下是我的组件的代码: var Bloodhound=require('typeahead.js') 导出默认值{ 数据:函数(){ var id='typeahead suggestion'+parseInt(Math.random()*100000); 返回{ 身份证件 默认建议:[], 查询:“” }; }, 道具:{ 参数:{ 类型:字符串, 默

我在使用Vuejs2.0和laravel 5.3。我从一个子组件(typeahead组件)发出一个自定义事件,并使用v-on指令捕获该事件

以下是我的组件的代码:


var Bloodhound=require('typeahead.js')
导出默认值{
数据:函数(){
var id='typeahead suggestion'+parseInt(Math.random()*100000);
返回{
身份证件
默认建议:[],
查询:“”
};
},
道具:{
参数:{
类型:字符串,
默认值:“项目”
},
价值:{
类型:字符串,
默认值:“”
},
课程:{
类型:字符串,
默认值:“”
},
显示键:{
类型:字符串,
默认值:“”
},
建议模板:{
类型:字符串,
默认值:“”
},
姓名:{
类型:字符串,
默认值:“Vue自动完成”
},
预取:{
类型:字符串,
默认值:“”
},
建议:{
类型:布尔型,
默认值:false
},
远程:{
类型:字符串,
默认值:“”
},
占位符:{
类型:字符串,
默认值:“”
},
本地:{
类型:数组,
默认值:函数(){
返回[];
}
},
响应包装器:{
类型:字符串,
默认值:“”
}
},
观察:{
本地:函数(newVal){
如果(本建议){
this.defaultSuggestions=[…newVal];
}
这是resetTypeahead();
}
},
挂载:函数(){
this.initTypeahead();
if(此.local.length){
this.defaultSuggestions=[…this.local];
}
},
方法:{
updateValue:函数(值){
这是。$emit('input',value);
},
formatValue:函数(){
this.$refs.input.value=this.value;
},
变压器:功能(响应){
if(this.responseWrapper){
response=response[this.responseWrapper];
}
if(this.defaultSuggestion&&this.local.length==0){
this.defaultSuggestions=response.splice(0,5);
}
返回响应;
},
侦探犬:函数(){
var bloodhoundConfig={};
如果(此预取){
var预取={
cache:false,
url:this.prefetch
};
如果(本建议){
预取={…预取,转换:this.transformer};
}
猎犬配置={prefetch};
}
如果(这是本地的){
猎犬配置={
本地人:这个本地人,
…猎犬配置
}
}
if(this.remote){
猎犬配置={
远程:{
url:this.remote,
通配符:“%QUERY”,
变换:这是变压器
},
…猎犬配置
}
}
返回猎犬配置;
},
parseTemplate:函数(数据){
var res=Vue.compile(this.suggestionTemplate);
var vm=新的Vue({
数据,
渲染:res.render,
staticRenderFns:res.staticRenderFns
}).$mount();
返回vm.$el;
},
getSource:function(){
var self=这个;
var bloodhoundConfig=this.bloodhoundOption();
var datumTokenizer=this.displayKey?Bloodhound.tokenizers.obj.whitespace(this.displayKey)
:Bloodhound.tokenizers.whitespace;
var引擎=新警犬({
datumTokenizer,
queryTokenizer:猎犬,标记,空白,
…猎犬配置
});
变量源=函数(q、同步、异步){
如果(q==''&&self.defaultSuggestions.length>0&&self.defaultSuggestion){
同步(自我默认建议);
}否则{
搜索引擎(q、同步、异步);
}
};
返回此.defaultSuggestion?来源:引擎;
},
resetTypeahead:function(){
$(document).find(“#”+this.id).typeahead('destroy');
this.initTypeahead();
},
initTypeahead:function(){
var self=这个;
var模板={};
if(此.suggestionTemplate){
模板={建议:self.parseTemplate}
};
变量数据集={
名称:'Typeahead Suggestion',
display:this.displayKey,
来源:this.getSource(),
模板
};