我有观察者的组件
props: {
propShow: { required: true, type: Boolean }
},
data() {
return {
show: this.propShow
}
},
watch: {
propShow: {
handler: (val, oldVal) => {
this.show = val;
}
}
}
Run Code Online (Sandbox Code Playgroud)
每当parent组件发生更改时,propShow此组件都必须更新其show属性.This组件还修改show属性,这就是为什么我需要两个:show和propShow,因为Vue.js不允许直接更改属性.
这条线
this.show = val;
Run Code Online (Sandbox Code Playgroud)
导致错误
TypeError: Cannot set property 'show' of undefined
Run Code Online (Sandbox Code Playgroud)
因为this内部处理程序是undefined.
为什么?
我有web应用程序,其中界面基于vue.js 2.0.
我有基于select2插件显示输入的组件.
默认情况下,它会显示所选的选项,但是当用户单击它时,我会显示select2以允许用户修改选项.
代码如下所示:
<template>
<div @click="toggleEdit">
<span v-show="isEnabled">
<select
class="form-control"
:name="name"
:multiple="multiple"
>
<option v-for="opt in options" :value="opt.id"> {{ opt.text }} </option>
</select>
</span>
<span v-show="!isEnabled">
<div v-if="selectedOptions.length === 0">
{{ emptyText }}
</div>
<div v-for="opt in selectedOptions">
{{ opt }}
</div>
</span>
</div>
</template>
<script>
export default {
props: {
options: {
type: Array,
required: false,
default: function() {
return []
}
},
name: {
required: true,
type: String
},
multiple: {
required: false,
type: Boolean,
default: …Run Code Online (Sandbox Code Playgroud) 这是我的server.js档案:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();
http.listen(3000, function(){
console.log('Listening on Port 3000');
});
redis.psubscribe('*', function(err, count) {
console.log(err, count);
});
redis.on('pmessage', function(subscribed, channel, message) {
message = JSON.parse(message);
io.emit(message.event, channel, message.data);
});
Run Code Online (Sandbox Code Playgroud)
一个简单的事件:
class FieldWasUpdated implements ShouldBroadcast
{
use InteractsWithSockets, SerializesModels;
public $instance;
public $key;
public $value;
public function __construct($instance, $key, $value)
{
$this->instance = $instance;
$this->key = $key;
$this->value = $value; …Run Code Online (Sandbox Code Playgroud) 使用此标记
<div @click='handleClickOnDiv'>
{{ message }}
<i class='fa fa-plus' @click='handleClickOnI'></i>
</div>
Run Code Online (Sandbox Code Playgroud)
当我点击div- 它调用handleClickOnDiv,但当我点击i- 它调用两个处理程序.
怎么处理呢?
我在vuex中有吸气剂,它从列表中返回项目
const store = new Vuex.Store({
state: { arr: {
1: {name: 'one', attr: true},
2: {name: 'two', attr: false}
},
mutations: {
setArrItemName(state, id, name) {
Vue.set(state.arr, id, name);
}
},
getters: {
arrItemById(state, getters) => (id) => {
const item = state.arr[id];
if(item) return item;
return {
name: 'default', attr: true
};
}
}
})
Run Code Online (Sandbox Code Playgroud)
如果我在模板中输出
{{ $store.state.arr[1]['name'] }}
Run Code Online (Sandbox Code Playgroud)
当另一部分调用时,它更新正常
this.$store.commit('setArrItemName', 1, 'new name');
Run Code Online (Sandbox Code Playgroud)
但是如果模板包含
{{ $store.getters.arrItemById(1).name }}
Run Code Online (Sandbox Code Playgroud)
然后它没有更新
问题:此getter在不同的地方使用,我不想重复此代码
<template v-if='$store.state.arr[id]'>
{{ $store.state.arr[id].name }}
</template>
Default
<template …Run Code Online (Sandbox Code Playgroud) 我已经删除了测试数据库,然后我想使用已保存的迁移创建新数据库:
2017_03_01_000000_create_api_table.php
2017_03_06_000000_create_beeline_calls.php
2017_03_13_000000_modify_beeline_emails.php
2017_03_14_000000_interactive_forms.php
2017_03_16_000000_model_instances.php
2017_03_24_000000_create_objects.php
2017_03_24_000001_create_objects_tables_v2.php
2017_03_24_000003_make_comments_without_users.php
2017_03_27_000000_add_processed_to_announcements.php
2017_03_29_000000_create_ads_channels.php
2017_03_29_000001_announcement_client.php
2017_04_06_000000_create_filters.php
2017_04_07_000000_create_new_input_types.php
Run Code Online (Sandbox Code Playgroud)
我跑的时候 php artisan migrate --pretend
[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'creator_id' on table 'application_model_instance_announcement_comments'.
Run Code Online (Sandbox Code Playgroud)
但是要运行的第一个迁移文件是 2017_03_01_000000_create_api_table.php
为什么它不是从一开始就运行的?数据库为空,migrations表为空.据我所知,Laravel应按字母顺序运行迁移文件.
vue.js ×4
laravel ×2
vuejs2 ×2
laravel-5.3 ×1
laravel-echo ×1
mysql ×1
socket.io ×1
vuex ×1
websocket ×1