Vue 路由器,如果 id 不匹配,则显示 404 页面(vue路由严格匹配)
25-04-27
1
此处将为大家介绍关于Vue路由器,如果id不匹配,则显示404页面的详细内容,并且为您解答有关vue路由严格匹配的相关问题,此外,我们还将为您介绍关于c–LNK2038:检测到’boost_log_a
此处将为大家介绍关于Vue 路由器,如果 id 不匹配,则显示 404 页面 的详细内容,并且为您解答有关vue路由严格匹配 的相关问题,此外,我们还将为您介绍关于c – LNK2038:检测到’boost_log_abi’不匹配:值’v2s_mt_nt5’与值’v2s_mt_nt6’不匹配、CommandLineParser - 如果没有给出开关,则显示 --help 结果、Django 管理面板:如果在下拉列表中选择了特定值,则显示/隐藏字段、Javascript:如果两个输入的值为x或y,则显示.div 的有用信息。
本文目录一览:
Vue 路由器,如果 id 不匹配,则显示 404 页面(vue路由严格匹配) 如何解决Vue 路由器,如果 id 不匹配,则显示 404 页面 如果参数不匹配,我不确定如何显示 404 页面?例如,如果用户名为“joe”,并且有人打开“/joe/categories”,则应显示类别组件。
现在,如果有人尝试打开“/james/categories”,我想添加保护,在这种情况下,我想进行重定向以显示 404 组件。我不确定我应该修复什么?我收到错误 “启动路由器时出现意外错误:错误:缺少必需的参数 ''catchAll''”
const routes = [
{
path : ''/:userName/categories'' , name : ''Categories'' , component : () => import ( /* webpackChunkName: "home" */ ''@/views/Categories'' ), props : true
},{
path : ''/:userName/products'' , name : ''Products'' , component : () => import ( /* webpackChunkName: "home" */ ''@/views/Products'' ),{
path : ''/:userName/settings'' , name : ''Settings'' , component : () => import ( /* webpackChunkName: "home" */ ''@/views/Settings'' ),{
path : ''/login'' , name : ''Login'' , component : () => import ( /* webpackChunkName: "login" */ ''@/views/Login'' )
},{
path : ''/registration'' , name : ''Registration'' , component : () => import ( /* webpackChunkName: "registration" */ ''@/views/Registration'' )
},{
path : ''/:catchAll(.*)'' , name : ''404'' , component : () => import ( /* webpackChunkName: "404" */ ''@/views/404'' )
}
]
router . beforeEach (( to , from , next ) => {
const isAuthenticated = store . getters [‘ users / isAuthenticated ’]
if (! isAuthenticated && to . name !== ‘ Login ’ && to . name !== ‘ Registration ’ && to . name !== ‘ 404 ’) {
next ({
name : ‘ Login ’
})
} else if ( isAuthenticated && store . getters [‘ users / getUserName ’] !== to . p ara ms . userName ) {
next ({
name : ‘ 404 ’
})
} else {
next ()
}
})
解决方法
我认为你可以这样做:
const routes = [
{
path : ''/:userName/categories'' , name : ''Categories'' , component : () => import ( /* webpackChunkName: "home" */ ''@/views/Categories'' ), props : true
},{
path : ''/:userName/products'' , name : ''Products'' , component : () => import ( /* webpackChunkName: "home" */ ''@/views/Products'' ),{
path : ''/:userName/settings'' , name : ''Settings'' , component : () => import ( /* webpackChunkName: "home" */ ''@/views/Settings'' ),{
path : ''/login'' , name : ''Login'' , component : () => import ( /* webpackChunkName: "login" */ ''@/views/Login'' )
},{
path : ''/registration'' , name : ''Registration'' , component : () => import ( /* webpackChunkName: "registration" */ ''@/views/Registration'' )
},{
path : ''*'' , name : ''404'' , component : () => import ( /* webpackChunkName: "404" */ ''@/views/404'' )
}
]
router . beforeEach (( to , from , next ) => {
const isAuthenticated = store . getters [‘ users / isAuthenticated ’]
if (! isAuthenticated && to . name !== ‘ Login ’ && to . name !== ‘ Registration ’ && to . name !== ‘ 404 ’) {
next ({
name : ‘ Login ’
})
} else if ( isAuthenticated && store . getters [‘ users / getUserName ’] !== to . params . userName ) {
next ({
name : ‘ 404 ’
})
} else {
next ()
}
})
c – LNK2038:检测到’boost_log_abi’不匹配:值’v2s_mt_nt5’与值’v2s_mt_nt6’不匹配 在创建包含boost库的单独头文件之后,我尝试包含在现有项目中.
但它显示以下错误:
:: Error 15 error LNK2038: mismatch detected for 'boost_log_abi':
value 'v2s_mt_nt5' doesn't match value 'v2s_mt_nt6' in BoostLogger.obj
E:\Projects\native\dcnotificationserver\loggerutil.obj ::
我知道以前的项目从Windows XP到当前Windows操作系统(即)10.
但是我读到了Windows XP提升支持.
问题是什么?
怎么解决?
我认为由于Windows版本的问题?
有关详细信息,请询问我.
编辑: 我正在使用: 编译器:msvc 10 提升版:1.60 Visual Studio 2010
解决方法
将BOOST升级到1.60并将Visual Studio升级到2015后,我遇到了类似的问题.
我通过将预处理器中的_WIN32_WINNT定义更改/定义为0x601副0x501来解决它.
我很确定这意味着……支持Win7和更强大的副XP.
CommandLineParser - 如果没有给出开关,则显示 --help 结果 如何解决CommandLineParser - 如果没有给出开关,则显示 --help 结果
使用 CommandLineParser NuGet,当我不带参数运行我的应用程序时,是否可以强制显示 --help 结果输出,就像我要运行我的应用程序一样......
myapplication.exe --help
目前,当我运行我的应用程序时,如果我没有指定任何选项,它不会显示帮助输出。它只是结束应用程序。我有许多不同的选项/标志/参数可以使用。他们都不应该被强迫自己,但我至少需要使用一个或显示帮助。
我目前的实现...
public class Options
{
[Option(
''v'',required = false,HelpText = "Shows all debug information when processing."
)]
public bool Verbose { get; set; }
[Option(
required = false,HelpText = "Runs Test One."
)]
public bool TestOne { get; set; }
}
static void Main(string[] args)
{
try
{
var parserResults = Parser.Default.ParseArguments<Options>(args);
parserResults
.WithParsed<Options>(options => Run(options));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("Main thread closing.");
}
static void Run(Options options)
{
// Verbose mode
if (options.Verbose)
{
m_Verbose = true;
Console.WriteLine("Verbose mode on.");
}
// Test
if (options.TestOne)
{
//do test
}
}
解决方法
我能够使用这两个技巧来完成这项工作:
https://github.com/commandlineparser/commandline/issues/138#issuecomment-341920340
https://github.com/commandlineparser/commandline/issues/138#issuecomment-527936051
这是一些示例代码:
using CommandLine;
using CommandLine.Text;
internal static class Main
{
public static void Main(string[] Arguments)
{
HelpText oHelpText;
ParserResult<Command.Options> oResult;
oResult = Parser.Default.ParseArguments<Command.Options>(Arguments);
oResult.Success(Options => Run(Options));
oHelpText = HelpText.AutoBuild(oResult,x => x,x => x);
Console.WriteLine(oHelpText);
Console.ReadLine();
}
private static void Run(Command.Options Options)
{
switch (Options.Type)
{
case Command.Types.Folder:
{
break;
}
case Command.Types.File:
{
break;
}
}
}
}
internal static class Extensions
{
public static ParserResult<Command.Options> Success(this ParserResult<Command.Options> Instance,Action<Command.Options> Action)
{
return Instance.WithParsed(Action);
}
public static ParserResult<Command.Options> Failure(this ParserResult<Command.Options> Instance,Action<Command.Options> Action)
{
return Instance.WithNotParsed(Action);
}
}
namespace Command
{
internal class Options
{
[Option("s","source",HelpText = "The source folder that contains the designated files/subfolders")]
public string Source { get; set; }
[Option("t","target",HelpText = "The target folder to which to move the files/subfolders")]
public string Target { get; set; }
[Option("y","type",HelpText = "The source type [File | Folder]")]
public Enums.Types Type { get; set; }
[Option("c","chunksize",HelpText = "The size of each chunk to move")]
public int ChunkSize { get; set; }
}
internal static class Enums
{
public enum Types
{
Folder,File
}
}
}
Django 管理面板:如果在下拉列表中选择了特定值,则显示/隐藏字段 如何解决Django 管理面板:如果在下拉列表中选择了特定值,则显示/隐藏字段 我做错了什么?
在 django 管理面板中,我想根据选择下拉列表显示/隐藏字段。此外,选择下拉列表位于父外键相关模型上,要显示/隐藏的字段位于子模型中或作为堆叠内联。
我已关注此 solution(stack overflow),但没有成功。
models.py
from django . db import models
CHOICES = (
( ''video'' , ''Video'' ),( ''text'' , ''Text'' ),( ''question'' , ''Question'' ),)
class Section ( models . Model ):
content_type = models . CharField ( max_length = 32 )
@property
def contents ( self ):
return self . content_set . all ()
class Content ( models . Model ):
content = models . ForeignKey ( Section , on_delete = models . DCASCADE )
video = models . FileField ()
text = models . TextField ()
question = models . CharField ( max_length = 512 )
admin.py
from django . contrib import admin
from . models import Section , Content
from . forms import DropdownModelForm
class ContentInline ( admin . StackedInline ):
model = Content
fieldsets = (
( None ,{
''fields'' : (( ''video'' ,), ''classes'' : ( ''vid'' ,)
}),( None ,{
''fields'' : (( ''text'' , ''classes'' : ( ''txt'' ,{
''fields'' : (( ''question'' , ''classes'' : ( ''ques'' ,)
})
)
class Media :
js = ( ''one/js/base.js'' ,)
@admin . register ( Section )
class SectionAdmin ( admin . ModelAdmin ):
form = DropdownModelForm
inli nes = ( ContentInline ,)
forms.py
from django import forms
from . models import Section , CHOICES
class DropdownModelForm ( forms . ModelForm ):
class Meta :
model = Section
fields = ( ''content_type'' ,)
widgets = {
''content_type'' : forms . Select ( choices = CHOICES )
}
base.js
( function ( $ ) {
$ ( function () {
var selectField = $ ( ''#id_content_type'' ), verified_1 = $ ( ''.vid'' ), verified_2 = $ ( ''.txt'' ), verified_3 = $ ( ''.ques'' );
function togg Lever ified ( value ) {
if ( value === ''video'' ) {
verified_1 . show ();
verified_2 . hide ();
verified_3 . hide ();
} else if ( value === ''text'' ) {
verified_1 . hide ();
verified_2 . show ();
verified_3 . hide ();
} else if ( value === ''question'' ) {
verified_1 . hide ();
verified_2 . hide ();
verified_3 . show ();
}
}
// show/hide on load based on perv IoU s value of selectField
togg Lever ified ( selectField . val ());
// show/hide on change
selectField . change ( function () {
togg Lever ified ( $ ( this ). val ());
});
});
})( django . jQuery );
settings.py
from pathlib import Path
BASE_DIR = Path ( __file__ ). resolve (). parent . parent
.
.
.
INSTALLED_APPS = [
''one.apps.OneCon fig '' , ''django.contrib.admin'' , ''django.contrib.auth'' , ''django.contrib.contenttypes'' , ''django.contrib.sessions'' , ''django.contrib.messages'' , ''django.contrib.staticfiles'' ,]
.
.
.
STATIC_URL = ''/static/''
STATICFILES_D irs = [
BASE_DIR / "static" ,]
再说一遍,我做错了什么?
在 django 管理面板中,我想根据选择下拉列表显示/隐藏字段。此外,选择下拉列表位于父外键相关模型上,要显示/隐藏的字段位于子模型中或作为堆叠内联。
我已经关注了这个 solution(stack overflow),但没有成功。
非常感谢您花费宝贵的时间并查看我糟糕的代码
解决方法
将 javascript 文件作为 admin.py
中的列表传递解决了这个问题。
class Media :
js = [ "one/js/base.js" ,]
另外,不知道为什么 jquery 不能正常工作。因此,为此将您的 javascript 包裹在 jQuery(document).ready(function ($) { ...your javascript... });
中,如
jQuery ( document ). ready ( function ( $ ) {
( function ( $ ) {
$ ( function () {
var selectField = $ ( ''#id_content_type'' ), verified_1 = $ ( ''.vid'' ), verified_2 = $ ( ''.txt'' ), verified_3 = $ ( ''.ques'' );
function toggleVerified ( value ) {
if ( value === ''video'' ) {
verified_1 . show ();
verified_2 . hide ();
verified_3 . hide ();
} else if ( value === ''text'' ) {
verified_1 . hide ();
verified_2 . show ();
verified_3 . hide ();
} else if ( value === ''question'' ) {
verified_1 . hide ();
verified_2 . hide ();
verified_3 . show ();
}
}
// show/hide on load based on pervious value of selectField
toggleVerified ( selectField . val ());
// show/hide on change
selectField . change ( function () {
toggleVerified ( $ ( this ). val ());
});
});
})( django . jQuery );
});
Javascript:如果两个输入的值为x或y,则显示.div 我有两个输入和一个div.当两个输入的值都为6或7时,我希望能够显示div.
我是javascript的新手.这就像我能够来的那样接近(我担心,不是这么接近):
var div = $('div').hide();
$('.first, .second').keyup(function() {
var value = this.value;
if (value == 6 || value == 7) {
div.fadeIn();
} else {
div.fadeOut();
}
});
JSFiddle
解决方法:
$('.first, .second').keyup(function() {
var value1 = $(".first").val();
var value2 = $(".second").val();
if ((value1 == 6 || value1 == 7) && (value2 == 6 || value2 == 7)) {
div.fadeIn();
} else {
div.fadeOut();
}
});
试试以上
关于Vue 路由器,如果 id 不匹配,则显示 404 页面 和vue路由严格匹配 的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于c – LNK2038:检测到’boost_log_abi’不匹配:值’v2s_mt_nt5’与值’v2s_mt_nt6’不匹配、CommandLineParser - 如果没有给出开关,则显示 --help 结果、Django 管理面板:如果在下拉列表中选择了特定值,则显示/隐藏字段、Javascript:如果两个输入的值为x或y,则显示.div 的相关知识,请在本站寻找。