你好,我在 laravel 项目中使用 vuejs,这是我的 vuejs 代码
Vue.component('search_and_select',{
template:
'<div>'+
'<slot :test_text="test_text"></slot>'+
'</div>',
data:function(){
return {
test_text:"test text",
}
},
methods:{
},
props:{
},
});
new Vue({
el:'.user_search_and_select',
data:{
},
});
Run Code Online (Sandbox Code Playgroud)
这是我的 html 代码
<div is='search_and_select'>
<div slot-scope="{test_text}">
@{{test_text}}
<input type='text' v-model='test_text' />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都工作得很好,但如果我键入,<input type='text' v-model='test_text' />则test_text不会改变仍然相同,所以我如何更改插槽并更改父组件,非常感谢..
我在 JavaScript 中使用 Vue.js。
我有一个被调用的对象数组,products每个对象都有被property调用的smallest_unit_barcode. 我只想过滤带有条形码的产品value,所以我做了这个功能:
if (value != '') {
var results = this.products.filter(obj=>obj.smallest_unit_barcode.includes(value));
var results = results.slice(Math.max(results.length - 20, 0))
this.pos_quick_lunch = results;
}
Run Code Online (Sandbox Code Playgroud)
一切正常,但如果obj.smallest_unit_barcode == null,我收到此错误:
Error in v-on handler: "TypeError: Cannot read property 'includes' of null"
Run Code Online (Sandbox Code Playgroud)
null过滤产品数组时如何忽略该值?