我有组件
我想点击后运行方法
<my-component @click="showOtherDiv"></my-component>
Run Code Online (Sandbox Code Playgroud)
我在主app方法上有这个方法
var app = new Vue({
el: '#app',
data: {},
methods: {
showOtherDiv : function(){
alert('Some message');
}
}
});
Run Code Online (Sandbox Code Playgroud)
但似乎"点击"不适用于完整组件
我想将文字粘贴到:
<div class="text" contenteditable="true"></div>
Run Code Online (Sandbox Code Playgroud)
然后粘贴后,我需要该文本将具有已删除的文本格式,但要保留新行。
我有这样的文字:
$(".text").bind({
paste: function () {
setTimeout(function () {
var text = $(".text").text();
$('.text').text(text);
}, 100);
}
});
Run Code Online (Sandbox Code Playgroud)
但这不是添加新行;
我怎么能覆盖孩子的父方法?是javascript有像parent :: method();
var Parent = function(){
this.myMethod(){
//Some code here
};
}
var Child = function(){
Parent.call(this);
this.myMethod(){
//Some code here
//and then run parent method
};
}
Run Code Online (Sandbox Code Playgroud)
更新有比这更好的方法(不是ES6)?:
var Parent = function ()
{
this.myMethod()
{
this.extedMyMethod()
//Some code here
};
this.extedMyMethod()
}
var Child = function ()
{
Parent.call(this);
this.extedMyMethod()
{
//Some code which expand parent method
};
}
Run Code Online (Sandbox Code Playgroud)
PS如果我喜欢@Suren Srapyan suguest webpack将转换为适当的非ES6?
我有带有自定义属性的模型
class MyModel extends Model
{
public function getExtraAttribute(){
return 'some string'; //etc.
}
}
Run Code Online (Sandbox Code Playgroud)
对于控制器方法我有这个
return MyModel::where('user_id', Auth::user()->id)->get();
Run Code Online (Sandbox Code Playgroud)
但是我没有在json响应上看到'额外'属性
PS额外不是数据库中的列。