我想访问state.session的instance.js距离records_view.js.这是如何完成的?
存储/模块/ instance.js
const state = {
// This is what I want to access in records_view.js
session: {}
};
const getters = {
sessionGetter: state => state.session
};
Run Code Online (Sandbox Code Playgroud)
存储/模块/ records_view.js
const actions = {
getSettingsAction (context, props) {
// This is how I'm trying to access session, which doesn't work
let session = context.state.instance.session;
Api(
context,
{
noun: props.noun,
verb: 'GetRecordsViewSettings',
orgUnitKey: _.has(session, 'orgunit.key') ? session.orgunit.key : '',
data: {}
},
props.callback
); …Run Code Online (Sandbox Code Playgroud) 我有以下Sass片段,我想让它<thead>在桌子滚动时浮动.这适用于Safari,但不适用于Chrome Version 58.0.3029.110 (64-bit).
我知道Chrome已经再次获得支持sticky,目前支持它,但它是最终的吗?这是Chrome错误还是我需要不同的解决方案?(我更喜欢CSS方法而不是Javascript,因为它更高效.)
.table {
thead {
background: white;
position: sticky;
top: 0;
z-index: 10;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个自定义查询,它从旧系统中获取数据并将其映射到新系统中的模型.查询如下所示:
$companies = DB::connection('legacy')->select("...");
由于它是大量数据,我想使用Eloquent的块功能(只是从他们的文档中复制的示例代码):
User::chunk(200, function($users)
{
foreach ($users as $user)
{
//
}
});
Run Code Online (Sandbox Code Playgroud)
我该如何实现?
编辑:我的代码现在看起来像这样,导致没有响应:
DB::connection('legacy')->select("SELECT * FROM companies")->chunk(200, function($companies) {
foreach ($companies as $company) {
// dd($company);
$entity = Entity::firstOrNew(['external_id' => $company->companyKey]);
$entity->name = $company->companyName;
$entity->save();
}
});
Run Code Online (Sandbox Code Playgroud) 目标
在不失去理智的情况下使路由工作.
错误
Error: Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?, ?)
Run Code Online (Sandbox Code Playgroud)
app.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { NavbarComponent } from './navbar/navbar.component';
import { CustomerComponent } from './customer/customer.component';
export const appRoutes: Routes = [
{ path: '', redirectTo: 'customers', pathMatch: 'full' },
{ path: 'customers', component: CustomerComponent },
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { NgModule } from '@angular/core';
import { …Run Code Online (Sandbox Code Playgroud) 我正在发出POST请求,但除422响应外无法获取其他任何内容。
Vue.js客户端代码:
new Vue({
el: '#app',
data: {
form: {
companyName: '',
street: '',
city: '',
state: '',
zip: '',
contactName: '',
phone: '',
email: '',
numberOfOffices: 0,
numberOfEmployees: 0,
}
},
methods: {
register: function() {
this.$http.post('/office-depot-register', this.form).then(function (response) {
// success callback
console.log(response);
}, function (response) {
// error callback
console.log(response);
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
Laravel路线:
Route::post('/office-depot-register', ['uses' => 'OfficeDepotController@register', 'as' => 'office-depot-register']);
Run Code Online (Sandbox Code Playgroud)
Laravel控制器:
public function register(Request $request)
{
$this->validate($request, [
'companyName' => 'required',
// ...
]);
// …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的HTTP响应中发回一个JSON编码的MongoDB对象.我跟着其他几个类似的问题,但我仍然遗漏了一些东西.没有异常被抛出,但我<api.views.MongoEncoder object at 0x80a0c02c>在浏览器中得到了一个神秘的回应.我相信这很简单,但任何帮助都会受到赞赏.
功能:
from django.utils.simplejson import JSONEncoder
from pymongo.objectid import ObjectId
class MongoEncoder( JSONEncoder ):
def _iterencode( self, o, markers = None ):
if isinstance( o, ObjectId ):
return """ObjectId("%s")""" % str(o)
else:
return JSONEncoder._iterencode(self, o, markers)
Run Code Online (Sandbox Code Playgroud)
views.py:
user = User({
's_email': request.GET.get('s_email', ''),
's_password': request.GET.get('s_password', ''),
's_first_name': request.GET.get('s_first_name', ''),
's_last_name': request.GET.get('s_last_name', ''),
'd_birthdate': request.GET.get('d_birthdate', ''),
's_gender': request.GET.get('s_gender', ''),
's_city': request.GET.get('s_city', ''),
's_state': request.GET.get('s_state', ''),
})
response = {
's_status': 'success',
'data': user
}
return HttpResponse(MongoEncoder( …Run Code Online (Sandbox Code Playgroud) 目标
我只想检测 的更改事件searchTerms。
问题
目前,观察者在每次按键时都会触发,但我不想要那么多事件。
上下文(查看小提琴)
<template>
<div id="app">
<table class="table">
<tr>
<td><label>Name</label></td>
<td><input class="form-control" v-model="customer.name" autofocus></td>
</tr>
<tr>
<td><label>Short Code</label></td>
<td><input class="form-control" v-model="customer.shortCode"></td>
</tr>
<tr>
<td><label>Address</label></td>
<td><input class="form-control" v-model="customer.address"></td>
</tr>
<tr>
<td><label>Caller</label></td>
<td><input class="form-control" v-model="customer.caller"></td>
</tr>
<tr>
<td><label>Phone</label></td>
<td><input class="form-control" v-model="customer.phone"></td>
</tr>
</table>
<div class="models">
<pre><strong>customer:</strong> {{ customer | json }}</pre>
<pre><strong>searchTerms:</strong> {{ searchTerms | json }}</pre>
</div>
</div>
</template>
<script>
new Vue({
el: '#app',
data: {
customer: {
name: 'Donnie',
phone: '',
caller: …Run Code Online (Sandbox Code Playgroud) 问题
我被困在一个循环中,运行时npm run watch说它找不到cross-spawn。
> @ watch /Users/donnie/Github/laravel_project
> npm run development -- --watch
> @ development /Users/donnie/Github/laravel_project
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
module.js:549
throw err;
^
Error: Cannot find module 'cross-spawn'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/donnie/.yarn-cache/npm-cross-env-5.2.0/dist/index.js:5:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ …Run Code Online (Sandbox Code Playgroud) 错误:413请求实体太大
我试图增加upload_max_filesize对20M使用Edit PHP FPM Configuration和Edit PHP CLI Configuration在Laravel锻造工具.它成功保存了我的设置,但更改似乎没有生效.我试过重启nginx和服务器.
环境:
我在这个查询中使用了多个运算符.我没有语法错误,但我没有得到任何数据(应该是),所以我很确定我正在查看逻辑错误.问题是,我没有看到它.
查询:
db.questions.find(
{'$and': [
{'answers.s_user_id': {'$ne': s_user_id}},
{'$or': [
{'s_text': re.compile(s_term, re.IGNORECASE)},
{'choices': re.compile(s_term, re.IGNORECASE)}
]}
]}
)
Run Code Online (Sandbox Code Playgroud)
任何提示都表示赞赏.
vue.js ×3
javascript ×2
laravel ×2
mongodb ×2
pymongo ×2
angular ×1
css ×1
django ×1
eloquent ×1
forge ×1
laravel-4 ×1
laravel-5.2 ×1
laravel-5.7 ×1
node.js ×1
npm ×1
php ×1
python ×1
sass ×1
simplejson ×1
vue-resource ×1
vuex ×1