似乎Vue.js 2.0不会将大孩子的事件发送到他的祖父组件.
Vue.component('parent', {
template: '<div>I am the parent - {{ action }} <child @eventtriggered="performAction"></child></div>',
data(){
return {
action: 'No action'
}
},
methods: {
performAction() { this.action = 'actionDone' }
}
})
Vue.component('child', {
template: '<div>I am the child <grand-child></grand-child></div>'
})
Vue.component('grand-child', {
template: '<div>I am the grand-child <button @click="doEvent">Do Event</button></div>',
methods: {
doEvent() { this.$emit('eventtriggered') }
}
})
new Vue({
el: '#app'
})
Run Code Online (Sandbox Code Playgroud)
这个JsFiddle解决了问题https://jsfiddle.net/y5dvkqbd/4/,但通过发布两个事件:
添加此中间事件似乎是重复且不必要的.有没有办法直接向祖父母发出我不知道的事情?
我用这种方式定义了控制器的路由:
/model/{id}/view
/model/something/{id}/edit
Run Code Online (Sandbox Code Playgroud)
我需要在此控制器的构造函数中获取id参数.例如 :
class ArtController extends Controller {
public function __construct(Request $request){
//dd($this->route('id')); //Doesn't work
//dd($request->segments()[1]); //this works for the first route but not the second
}
}
Run Code Online (Sandbox Code Playgroud)
如何id在Laravel中的Controller的构造函数中获取参数?
下载了elasticsearch并按照此链接中的步骤解压缩后:
我收到以下错误:
Error: missing 'server' JVM at 'C:\Program Files (x86)\Java\jre1.8.0_131\bin\server\jvm.dll'.
Please install or use the JRE or JDK that contains these missing components.
Run Code Online (Sandbox Code Playgroud)
注意:我还必须按照此解决方案的建议安装JDK8
我应该更改.config文件中的内容吗?也许这一行?
# force the server VM (remove on 32-bit client JVMs)
-server
Run Code Online (Sandbox Code Playgroud) 恕我直言,当前用于在Laravel中保存通知的数据库通道是非常糟糕的设计:
data列中搜索自定义属性(转换为Array)不是最佳选择您将如何DatabaseNotification在供应商包中扩展模型?
我想添加列event_id,question_id,user_id(在创建该通知用户)等等为默认laravel notifications表
如何覆盖send函数以包含更多列?
在:
vendor/laravel/framework/src/Illuminate/Notifications/Channels/DatabaseChannel.php
Run Code Online (Sandbox Code Playgroud)
代码:
class DatabaseChannel
{
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return \Illuminate\Database\Eloquent\Model
*/
public function send($notifiable, Notification $notification)
{
return $notifiable->routeNotificationFor('database')->create([
'id' => $notification->id,
'type' => get_class($notification),
\\I want to add these
'user_id' => \Auth::user()->id,
'event_id' => $notification->type =='event' ? $notification->id : null,
'question_id' => $notification->type =='question' ? …Run Code Online (Sandbox Code Playgroud) 我正在Laravel 5上设置一个迁移,并且想知道是否有一些关于每个列类型的默认长度的文档?他们是否遵循像MySQL这样的惯例?
例如:INTEGER,TEXT,MEDIUMTEXT,LONGTEXT
我在谈论这些列类型:(http://laravel.com/docs/5.0/schema#adding-columns)
我开始使用Mean JS样板(ref网站),并想知道推荐的位置包括公共自定义javascript,jQuery文件(例如FacebookSDK,jQuery动画,......).
我假设它将在公共文件夹中的某个位置.默认结构如下:
应该进入模块还是lib文件夹?您能否就每个文件夹的功能提供更多指导?任何准则?
我正在尝试显示活动议程上的项目列表。
事件有一个start_date结束,议程上的每个项目都有一个duration以分钟为单位的时间,例如:
event:{
start_date: '2017-03-01 14:00:00',
agendas:[
{id:1,duration:10},
{id:2,duration:15},
{id:3,duration:25},
{id:4,duration:10}
]
}
Run Code Online (Sandbox Code Playgroud)
现在,在我的event组件中,我加载agendas了一个v-for:
<agenda v-for="(agenda,index) in event.agendas"
:key="agenda.id"
:index="index"
:agenda="agenda">
Run Code Online (Sandbox Code Playgroud)
在agenda组件中,我想增加每个项目开始的时间:
<div class="agenda">
//adding minutes to start_date with momentJs library
{{ moment(event.start_date).add(agenda.duration,'m') }} //this should increment, not add to the fixed event start date
</div>
Run Code Online (Sandbox Code Playgroud)
目前它只添加到固定事件start_date......我想显示14:00事件1,14:10事件2,14:25事件3和14:50事件的时间4。
如何v-for在 …
我想设置一个固定的背景图像,该图像也覆盖 div,但是由于某些原因,当我将固定添加到CSS时,图像会拉伸到超出div边界的范围。
这是2个示例,一个示例具有固定的尺寸(不正确的尺寸),另一个具有正确的尺寸,但它不是固定的(它随页面滚动)
#incorrect{
min-height:100px;
background: url('http://034.83e.myftpupload.com/wp-content/uploads/2015/04/entete_image.png') no-repeat fixed center/cover;
}
#correct{
min-height:100px;
background: url('http://034.83e.myftpupload.com/wp-content/uploads/2015/04/entete_image.png') no-repeat center/cover;
}Run Code Online (Sandbox Code Playgroud)
<div id="incorrect"></div>
<br>
<div id="correct"></div>Run Code Online (Sandbox Code Playgroud)
您如何使这两个属性一起工作?它们不兼容吗?
编辑:由于某种原因,固定属性是相对于视口而不是元素本身的,屏幕越高,图像获得的越大。有没有转机?
phpmyAdmin YEAR_MONTH()在查询编辑器中建议了一个自动完成的功能,我在网上找不到任何地方。如果此功能存在,那将是非常棒的。
可以?如果是,将如何使用它?
我想在子组件发出事件后执行一个简单的函数。问题在于子组件会发出我需要的数据作为函数的参数。
如何在组件的一行中注入参数并运行函数?
<div v-on:posted="runTask"> </div>
Run Code Online (Sandbox Code Playgroud)
要么
<div @posted="runTask"> </div>
Run Code Online (Sandbox Code Playgroud)
重要提示:我希望它适合模板(v-on:event或@event),因为我想将组件保留在PHP刀片模板中。
父级app有一个对象messages,该对象已从服务器正确填充。但是chat-room组件的道具messages不是由父母的道具喂养的messages。我想念什么?
这是我的刀片模板:
<chat-room></chat-room>
<chat-composer v-on:messagesent="addMessage"></chat-composer>
Run Code Online (Sandbox Code Playgroud)
这是我的chat-room组件:
<template>
<div class="chat-room">
<chat-message v-for="message in messages" :message="message"></chat-message>
</div>
</template>
<script>
export default {
props : ['messages'],
}
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的app.js:
Vue.component('chat-message', require('./components/ChatMessage.vue'));
Vue.component('chat-room', require('./components/ChatRoom.vue'));
Vue.component('chat-composer', require('./components/ChatComposer.vue'));
const app = new Vue({
el: '#app',
data: {
messages: []
},
methods: {
addMessage(message) {
this.messages.push(message);
axios.post(base_url+'/room/1/write_message', message).then(response => { });
}
},
created() {
axios.get(base_url+'/room/1/messages').then(response => {
this.messages = response.data;
console.log(this.messages); //this returns an …Run Code Online (Sandbox Code Playgroud)