小编Ano*_*ous的帖子

如何在Vue 2中查看数据对象中的所有键

我的数据对象:

data: {
    selected: {
        'type': null,
        'instrument': null
    },
Run Code Online (Sandbox Code Playgroud)

我的模板:

<select v-model="selected['instrument']" @change="switchFilter('instrument', $event)">
    <option v-for="instrument in instruments" :value="instrument.value">@{{ instrument.text }}</option> 
</select>

<select v-model="selected['type']" @change="switchFilter('type', $event)">
    <option v-for="type in types" :value="type.value">@{{ type.text }}</option> 
</select>
Run Code Online (Sandbox Code Playgroud)

如何同时查看两个选定的索引?每当任何索引更新时,我想做类似的事情:

watch: {
    selected: function(o, n) {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

watch vue.js vuejs2

14
推荐指数
3
解决办法
1万
查看次数

Laravel Eloquent或者哪里不是空的

我正在使用frozennode的Laravel Administrator软件包.长话短说,我在显示软删除的结果时遇到了问题.我正在尝试覆盖默认查询:

select * from `scripts` where `scripts`.`deleted_at` is null group by `scripts`.`id`
Run Code Online (Sandbox Code Playgroud)

要显示已删除的结果和未删除的结果,请以某种方式进行黑客攻击.这不是最优雅的解决方案,但我没有看到任何其他方式来做到这一点.所以,我的目标是这样做:

select * from `scripts` where `scripts`.`deleted_at` is null or `scripts`.`deleted_at` is not null group by `scripts`.`id`
Run Code Online (Sandbox Code Playgroud)

不幸的是我不知道如何使用orWhere()和'is not null'.经过一番研究后,我尝试使用原始SQL块,如下所示:

'query_filter'=> function($query) {
    $query->orWhere(DB::raw('`scripts`.`deleted_at` is not null'));
},
Run Code Online (Sandbox Code Playgroud)

但我最终得到了一个额外的SQL,因为它不包括orWhere()中的第二个参数:

select * from `scripts` where `scripts`.`deleted_at` is null or `scripts`.`deleted_at` is not null **is null** group by `scripts`.`id`
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

php sql administrator laravel eloquent

13
推荐指数
1
解决办法
4万
查看次数

使用 Apache 部署 Vue:路由在历史模式下不起作用

我在使用 Apache(也是 HTTPs)部署 vue 应用程序(没有数据库也没有服务器端代码)时遇到问题。这是我的 .conf 文件:

<VirtualHost *:80>
ServerAdmin myemail@gmail.com
ServerName mydomain.me
ServerAlias www.mydomain.me
DocumentRoot /var/www/mydomain.me/dist
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/mydomain.me/dist>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.me [OR]
RewriteCond %{SERVER_NAME} =www.mydomain.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

当我访问 mydomain 时,首页已正确加载(使用 构建的 index.html npm run build),但是没有任何路由工作(即 /portfolio)。

但是,如果我将路由器模式从 切换historyhash,则一切正常 ( /#/portfolio),但我想保持history模式处于活动状态。

提前致谢!

apache vue.js vue-router

3
推荐指数
2
解决办法
5783
查看次数

标签 统计

vue.js ×2

administrator ×1

apache ×1

eloquent ×1

laravel ×1

php ×1

sql ×1

vue-router ×1

vuejs2 ×1

watch ×1