我有两个<Route>用react-router创建的.
当用户点击"返回列表"时,我想滚动用户在列表中的位置.
我怎样才能做到这一点?
javascript scrollview reactjs react-router-v4 react-router-dom
我尝试安装auto-complete和auto-complete-clang-async.当我写这样的东西时std::,emacs说"自动完成不活跃".
我的自动完成配置是:
(require 'auto-complete)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete/dict")
(set-default 'ac-c-sources
'(ac-source-abbrev
ac-source-dictionary
ac-source-yasnippet
ac-source-words-in-buffer
ac-source-words-in-same-mode-buffers
ac-source-semantic))
(ac-config-default)
(dolist (m '(c-mode c++-mode java-mode))
(add-to-list 'ac-modes m))
(global-auto-complete-mode t)
;auto-complete-clang-async
(require 'auto-complete-clang-async)
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)
(defun my-ac-config ()
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(global-auto-complete-mode t))
(my-ac-config)
Run Code Online (Sandbox Code Playgroud)
错误是:
auto-complete error: (void-variable ac-source-c)
Run Code Online (Sandbox Code Playgroud) 我需要建立一个多实体搜索。
我不想每个T1,然后每个T2。
使用时fos:lastica:populate,出现错误:
拒绝将映射更新更新为[search_dev],因为最终映射将具有1种以上的类型:[t1,t2]
我的映射:
fos_elastica:
clients:
default:
host: %elastic_host%
port: %elastic_port%
indexes:
search:
finder: ~
client: default
index_name: search_%kernel.environment%
types:
t1:
indexable_callback: 'getEnabled'
properties:
id:
type: integer
name: ~
persistence:
driver: orm
model: AppBundle\Entity\T1
finder: ~
listener:
logger: true
elastica_to_model_transformer:
ignore_missing: true
t2:
indexable_callback: 'getEnabled'
properties:
id:
type: integer
name: ~
persistence:
driver: orm
model: AppBundle\Entity\T2
finder: ~
listener:
logger: true
elastica_to_model_transformer:
ignore_missing: true
Run Code Online (Sandbox Code Playgroud)
我的服务:
$search = $this->indexManager->getIndex('search')->createSearch();
$search->addType('t1');
$search->addType('t2');
$resultSet = $search->search($query);
$results = $this->modelTransformer->transform($resultSet->getResults());
Run Code Online (Sandbox Code Playgroud)
我错过了什么?我可以在1个索引中映射2种类型吗?
我有2个文件。
服务.yaml
imports:
- { resource: services/service_test.yaml }
services:
_defaults:
autowire: true
autoconfigure: true
Run Code Online (Sandbox Code Playgroud)
和 service_test.yaml
services:
_defaults:
autowire: true
autoconfigure: true
App\Test\TestAbstract:
abstract: true
App\Test\TestA:
parent: App\Test\TestAbstract
autowire: false
autoconfigure: false
tags:
- { name: app.test }
App\Test\TestManager:
arguments: [!tagged { tag: 'app.test' }]
Run Code Online (Sandbox Code Playgroud)
我的类 TestManager 有一个构造函数
public function __construct(iterable $tests, LoggerInterface $logger)
{
dump($tests);
$this->logger = $logger;
}
Run Code Online (Sandbox Code Playgroud)
使用该配置我遇到错误:
Cannot autowire service "App\Test\TestManager": argument "$tests" of method "__construct()" is type-hinted "iterable", you should configure its value explicitly.
Run Code Online (Sandbox Code Playgroud)
如何使用 …
我在API模式下使用Rails 5启动了一个新项目。
目前,我只是创建项目,设置数据库并使用scaffold命令。
rails g scaffold User
Run Code Online (Sandbox Code Playgroud)
我尝试用邮递员的代码创建一个新用户(POST)
请求
URI localhost:3000/v1/users
{
"first_name": "Firstname",
"last_name": "Lastname",
"email": "anemail@gmail.com32"
}
Run Code Online (Sandbox Code Playgroud)
结果
#<NoMethodError: undefined method `user_url' for #<Api::V1::UsersController:0x005594d8a4ad90>
Run Code Online (Sandbox Code Playgroud)
我该如何解决该错误?
routes.rb
Rails.application.routes.draw do
scope module: 'api' do
namespace :v1 do
resources :users, :as => 'user'
end
end
end
Run Code Online (Sandbox Code Playgroud)
users_controller.rb
# POST /users
def create
@user = User.new(user_params)
if @user.save
render json: @user, status: :created, location: @user
else
render json: @user.errors, status: :unprocessable_entity
end
end
Run Code Online (Sandbox Code Playgroud) 我想重写 Router::navigate 并直接在 Router 类中执行一些代码(例如日志)
export const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
}
];
export function routerFactory(rootComponentType: Type<any> | null, urlSerializer: UrlSerializer,
rootContexts: ChildrenOutletContexts, location: Location,
injector: Injector, loader: NgModuleFactoryLoader,
compiler: Compiler, config: Router): Router {
return new MyRouter(
rootComponentType,
urlSerializer,
rootContexts,
location,
injector,
loader,
compiler,
config
);
}
@NgModule({
declarations: [
AppComponent,
...
],
imports: [
routing,
...
],
providers: [
...
{
provide: Router,
useFactory: routerFactory,
deps: [Type, UrlSerializer, ChildrenOutletContexts, Location, Injector, …Run Code Online (Sandbox Code Playgroud) 我想在我的 smarty 模板中调用 php 方法。
我有课
class TestClass
{
public static myMth($vars) {
var_dump($vars);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的模板中我输入:
{TestClass::myMth($someVar)}
Run Code Online (Sandbox Code Playgroud)
那是行不通的。我有错误:
解析错误:语法错误,意外的“myMth”(T_STRING),期望变量(T_VARIABLE)
我的代码有问题吗?
我使用 php 8.1.2 将项目从 SF 5.4 升级到 SF 6。
在我的开发环境中,我没有错误!
当我使用 prod env 清除缓存时出现错误:
In Route.php line 196:
Typed property Symfony\Component\Routing\Annotation\Route::$env must not be accessed before initialization
Run Code Online (Sandbox Code Playgroud)
我尝试删除 var/cache 文件夹。
您有任何想法如何解决这个问题吗?
我在堆栈中发现了相同的错误,并将 handler_id 替换为空值。
该错误来自 SF 路由器供应商。Route.php 不是我自己的代码。
为什么我的 Makefile 不起作用?
生成文件:
app-reset:
bin/console avanzu:admin:fetch-vendor
Run Code Online (Sandbox Code Playgroud)
make app-reset正在返回:
makefile:3: *** target pattern contains no `%'. Stop.
Run Code Online (Sandbox Code Playgroud) 我正在使用Sharepoint网站.我无权访问webparts代码.我只能用JavaScript更改母版页.
其中一个webpart有一个bug.它改变了<img>一个坏的SRC值.
例:
应该有
<img alt="img" src="http://www.apicture.png" style="margin:5px" /><br /><br />
Run Code Online (Sandbox Code Playgroud)
但有
<img alt="img" src="<a href="http://www.apicture.png">http://www.apicture.png</a>" style="margin:5px" /><br /><br />
Run Code Online (Sandbox Code Playgroud)
我试图匹配和替换,但innerHtml打破了其他脚本.
如何使用JavaScript修复我的?
编辑:
我有代码:
var markup = document.documentElement.innerHTML;
markup = markup.replace(/src=\".*?(http:\/\/[^\"]+)\"/g,'src=\"$1\"');
document.documentElement.innerHTML = markup;
Run Code Online (Sandbox Code Playgroud)
但它打破了我的网页.
我有一个 RestApi,我想将它与我的 c# mvc 客户端一起使用。
我需要发送一些由 ac# 模型表示的数据包。
我尝试使用 RestSharp 代码:
//model = UserModel
var client = new RestClient(apiUrl);
var request = new RestRequest("/user/register", Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddParameter("user", model);
request.AddHeader("Content-Type", "application/json; charset=UTF-8");
var response = client.Execute(request);
Run Code Online (Sandbox Code Playgroud)
在response.StatusCode中我有BadRequest System.Net.HttpStatusCode
我如何调试我的请求?我尝试使用wireshark 查看请求,但没有看到任何json 数据包。
编辑:
当我使用 AddJsonBody 而不是 AddParameter 时,它可以工作,但我的 json 数据包的格式不符合预期。
我想
{
"user":
{"Username": "Test",
"Password": "password"
}
}
Run Code Online (Sandbox Code Playgroud)
使用 AddJsonBody 我有:
{
{
"Username": "Test",
"Password": "password"
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用 RestSharp 在 json 数据包中给出“名称”?
javascript ×2
php ×2
symfony ×2
angular ×1
autocomplete ×1
c# ×1
elisp ×1
emacs ×1
emacs24 ×1
makefile ×1
rails-api ×1
reactjs ×1
rest ×1
restsharp ×1
scrollview ×1
sharepoint ×1
smarty ×1
symfony-4.3 ×1