[HttpGet]
[Route("~/search/{clause}/{skip?}")]
public async Task<ActionResult> Search(string clause, int skip = 0)
{
...
}
@using (Html.BeginForm("Index", "search", FormMethod.Get))
{
@Html.TextBox("clause", null, new { @class = "form-control col-md-4" })
...
}
<form action="/search" method="get">
<input id="clause" name="clause" type="text" value="test">
</form>
我正在使用[HttpGet]
部分是因为我希望搜索能够通过http://myapp.com/search/<search values>
当我导航到http://myapp.com/search/test
时,一切似乎都很好,但当我尝试在文本框中输入我的新搜索字词并按Enter或提交时,它会导航到http://myapp.com/search?clause=newsearch
我该怎么做才能让我的文本框导航到http://myapp.com/search/newsearch
?
答案 0 :(得分:0)
您的表单生成{ [Error: ./resources/assets/js/app.js
Module build failed: ReferenceError: Unknown plugin "add-module-exports" specified in "base" at 0, attempted to resolve relative to "D:\\php7\\htdocs\\addbook\\
resources\\assets\\js" at D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\file\options\option-manager.js:176:17
at Array.map (native) at Function.normalisePlugins (D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\file\options\option-manager.js:154:20)
at OptionManager.mergeOptions (D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\file\options\option-manager.js:229:36)
at OptionManager.init (D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\file\options\option-manager.js:374:12)
at File.initOptions (D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\file\index.js:216:65)
at new File (D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\file\index.js:139:24)
at Pipeline.transform (D:\php7\htdocs\addbook\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (D:\php7\htdocs\addbook\node_modules\babel-loader\index.js:38:20)
at Object.module.exports (D:\php7\htdocs\addbook\node_modules\babel-loader\index.js:131:12)]
message: './resources/assets/js/app.js\nModule build failed: ReferenceError: Unknown plugin "add-module-exports" specified in "base" at 0, attempted to resolv
e relative to "D:\\\\php7\\\\htdocs\\\\addbook\\\\resources\\\\assets\\\\js"\n at D:\\php7\\htdocs\\addbook\\node_modules\\babel-core\\lib\\transformation\\f
ile\\options\\option-manager.js:176:17\n at Array.map (native)\n at Function.normalisePlugins (D:\\php7\\htdocs\\addbook\\node_modules\\babel-core\\lib\\t
ransformation\\file\\options\\option-manager.js:154:20)\n at OptionManager.mergeOptions (D:\\php7\\htdocs\\addbook\\node_modules\\babel-core\\lib\\transforma
tion\\file\\options\\option-manager.js:229:36)\n at OptionManager.init (D:\\php7\\htdocs\\addbook\\node_modules\\babel-core\\lib\\transformation\\file\\optio
ns\\option-manager.js:374:12)\n at File.initOptions (D:\\php7\\htdocs\\addbook\\node_modules\\babel-core\\lib\\transformation\\file\\index.js:216:65)\n at
new File (D:\\php7\\htdocs\\addbook\\node_modules\\babel-core\\lib\\transformation\\file\\index.js:139:24)\n at Pipeline.transform (D:\\php7\\htdocs\\addboo
k\\node_modules\\babel-core\\lib\\transformation\\pipeline.js:46:16)\n at transpile (D:\\php7\\htdocs\\addbook\\node_modules\\babel-loader\\index.js:38:20)\n
at Object.module.exports (D:\\php7\\htdocs\\addbook\\node_modules\\babel-loader\\index.js:131:12)',
showStack: false,
showProperties: true,
plugin: 'webpack-stream',
__safety: { toString: [Function: bound ] } }
,因为浏览器不了解您的路由(服务器上运行的c#代码)。
为了生成您首选的网址(var elixir = require('laravel-elixir');
require('laravel-elixir-vue');
elixir(function(mix) {
mix.sass('app.scss');
});
elixir(function(mix) {
mix.webpack('app.js');
});
elixir(function(mix) {
mix.version(['css/app.css', 'js/app.js']);
});
),您需要javascript来拦截并取消默认提交,并构建一个网址以导航到。使用jQuery:
http://myapp.com/search?clause=newsearch