GVKun编程网logo

Vue 路由器,如果 id 不匹配,则显示 404 页面(vue路由严格匹配)

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 页面(vue路由严格匹配)

如何解决Vue 路由器,如果 id 不匹配,则显示 404 页面

如果参数不匹配,我不确定如何显示 404 页面?例如,如果用户名为“joe”,并且有人打开“/joe/categories”,则应显示类别组件。 现在,如果有人尝试打开“/james/categories”,我想添加保护,在这种情况下,我想进行重定向以显示 404 组件。我不确定我应该修复什么?我收到错误 “启动路由器时出现意外错误:错误:缺少必需的参数 ''catchAll''”

  1. const routes = [
  2. {
  3. path: ''/:userName/categories'',name: ''Categories'',component: () => import(/* webpackChunkName: "home" */''@/views/Categories''),props: true
  4. },{
  5. path: ''/:userName/products'',name: ''Products'',component: () => import(/* webpackChunkName: "home" */''@/views/Products''),{
  6. path: ''/:userName/settings'',name: ''Settings'',component: () => import(/* webpackChunkName: "home" */''@/views/Settings''),{
  7. path: ''/login'',name: ''Login'',component: () => import(/* webpackChunkName: "login" */''@/views/Login'')
  8. },{
  9. path: ''/registration'',name: ''Registration'',component: () => import(/* webpackChunkName: "registration" */''@/views/Registration'')
  10. },{
  11. path: ''/:catchAll(.*)'',name: ''404'',component: () => import(/* webpackChunkName: "404" */''@/views/404'')
  12. }
  13. ]
  14. router.beforeEach((to,from,next) => {
  15. const isAuthenticated = store.getters[‘users/isAuthenticated’]
  16. if (!isAuthenticated && to.name !== Login && to.name !== Registration && to.name !== 404’) {
  17. next({
  18. name: Login
  19. })
  20. } else if (isAuthenticated && store.getters[‘users/getUserName’] !== to.params.userName) {
  21. next({
  22. name: 404
  23. })
  24. } else {
  25. next()
  26. }
  27. })

解决方法

我认为你可以这样做:

  1. const routes = [
  2. {
  3. path: ''/:userName/categories'',name: ''Categories'',component: () => import(/* webpackChunkName: "home" */''@/views/Categories''),props: true
  4. },{
  5. path: ''/:userName/products'',name: ''Products'',component: () => import(/* webpackChunkName: "home" */''@/views/Products''),{
  6. path: ''/:userName/settings'',name: ''Settings'',component: () => import(/* webpackChunkName: "home" */''@/views/Settings''),{
  7. path: ''/login'',name: ''Login'',component: () => import(/* webpackChunkName: "login" */''@/views/Login'')
  8. },{
  9. path: ''/registration'',name: ''Registration'',component: () => import(/* webpackChunkName: "registration" */''@/views/Registration'')
  10. },{
  11. path: ''*'',name: ''404'',component: () => import(/* webpackChunkName: "404" */''@/views/404'')
  12. }
  13. ]
  14. router.beforeEach((to,from,next) => {
  15. const isAuthenticated = store.getters[‘users/isAuthenticated’]
  16. if (!isAuthenticated && to.name !== Login && to.name !== Registration && to.name !== 404’) {
  17. next({
  18. name: Login
  19. })
  20. } else if (isAuthenticated && store.getters[‘users/getUserName’] !== to.params.userName) {
  21. next({
  22. name: 404
  23. })
  24. } else {
  25. next()
  26. }
  27. })

c – LNK2038:检测到’boost_log_abi’不匹配:值’v2s_mt_nt5’与值’v2s_mt_nt6’不匹配

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 - 如果没有给出开关,则显示 --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 管理面板:如果在下拉列表中选择了特定值,则显示/隐藏字段

我做错了什么?
在 django 管理面板中,我想根据选择下拉列表显示/隐藏字段。此外,选择下拉列表位于父外键相关模型上,要显示/隐藏的字段位于子模型中或作为堆叠内联。
我已关注此 solution(stack overflow),但没有成功。

models.py

  1. from django.db import models
  2. CHOICES = (
  3. (''video'',''Video''),(''text'',''Text''),(''question'',''Question''),)
  4. class Section(models.Model):
  5. content_type = models.CharField(max_length=32)
  6. @property
  7. def contents(self):
  8. return self.content_set.all()
  9. class Content(models.Model):
  10. content = models.ForeignKey(Section,on_delete=models.DCASCADE)
  11. video = models.FileField()
  12. text = models.TextField()
  13. question = models.CharField(max_length=512)

admin.py

  1. from django.contrib import admin
  2. from .models import Section,Content
  3. from .forms import DropdownModelForm
  4. class ContentInline(admin.StackedInline):
  5. model = Content
  6. fieldsets = (
  7. (None,{
  8. ''fields'': ((''video'',),''classes'': (''vid'',)
  9. }),(None,{
  10. ''fields'': ((''text'',''classes'': (''txt'',{
  11. ''fields'': ((''question'',''classes'': (''ques'',)
  12. })
  13. )
  14. class Media:
  15. js = (''one/js/base.js'',)
  16. @admin.register(Section)
  17. class SectionAdmin(admin.ModelAdmin):
  18. form = DropdownModelForm
  19. inlines = (ContentInline,)

forms.py

  1. from django import forms
  2. from .models import Section,CHOICES
  3. class DropdownModelForm(forms.ModelForm):
  4. class Meta:
  5. model = Section
  6. fields = (''content_type'',)
  7. widgets = {
  8. ''content_type'': forms.Select(choices=CHOICES)
  9. }

base.js

  1. (function($) {
  2. $(function() {
  3. var selectField = $(''#id_content_type''),verified_1 = $(''.vid''),verified_2 = $(''.txt''),verified_3 = $(''.ques'');
  4. function toggLeverified(value) {
  5. if (value === ''video'') {
  6. verified_1.show();
  7. verified_2.hide();
  8. verified_3.hide();
  9. } else if (value === ''text'') {
  10. verified_1.hide();
  11. verified_2.show();
  12. verified_3.hide();
  13. } else if (value === ''question'') {
  14. verified_1.hide();
  15. verified_2.hide();
  16. verified_3.show();
  17. }
  18. }
  19. // show/hide on load based on pervIoUs value of selectField
  20. toggLeverified(selectField.val());
  21. // show/hide on change
  22. selectField.change(function() {
  23. toggLeverified($(this).val());
  24. });
  25. });
  26. })(django.jQuery);

settings.py

  1. from pathlib import Path
  2. BASE_DIR = Path(__file__).resolve().parent.parent
  3. .
  4. .
  5. .
  6. INSTALLED_APPS = [
  7. ''one.apps.OneConfig'',''django.contrib.admin'',''django.contrib.auth'',''django.contrib.contenttypes'',''django.contrib.sessions'',''django.contrib.messages'',''django.contrib.staticfiles'',]
  8. .
  9. .
  10. .
  11. STATIC_URL = ''/static/''
  12. STATICFILES_Dirs = [
  13. BASE_DIR / "static",]

再说一遍,我做错了什么?
在 django 管理面板中,我想根据选择下拉列表显示/隐藏字段。此外,选择下拉列表位于父外键相关模型上,要显示/隐藏的字段位于子模型中或作为堆叠内联。
我已经关注了这个 solution(stack overflow),但没有成功。

非常感谢您花费宝贵的时间并查看我糟糕的代码

解决方法

javascript 文件作为 admin.py 中的列表传递解决了这个问题。

  1. class Media:
  2. js = ["one/js/base.js",]

另外,不知道为什么 jquery 不能正常工作。因此,为此将您的 javascript 包裹在 jQuery(document).ready(function ($) { ...your javascript... }); 中,如

  1. jQuery(document).ready(function ($) {
  2. (function ($) {
  3. $(function () {
  4. var selectField = $(''#id_content_type''),verified_1 = $(''.vid''),verified_2 = $(''.txt''),verified_3 = $(''.ques'');
  5. function toggleVerified(value) {
  6. if (value === ''video'') {
  7. verified_1.show();
  8. verified_2.hide();
  9. verified_3.hide();
  10. } else if (value === ''text'') {
  11. verified_1.hide();
  12. verified_2.show();
  13. verified_3.hide();
  14. } else if (value === ''question'') {
  15. verified_1.hide();
  16. verified_2.hide();
  17. verified_3.show();
  18. }
  19. }
  20. // show/hide on load based on pervious value of selectField
  21. toggleVerified(selectField.val());
  22. // show/hide on change
  23. selectField.change(function () {
  24. toggleVerified($(this).val());
  25. });
  26. });
  27. })(django.jQuery);
  28. });

Javascript:如果两个输入的值为x或y,则显示.div

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的相关知识,请在本站寻找。

本文标签:

上一篇是否可以为单独的 axios 实例创建单独的 vue 路由器?

下一篇错误 TS2709:无法使用命名空间“路由器”作为 angular 11.2 中的类型(无法使用名称创建文件,因为它包含无效字符)