小编Dan*_*Dan的帖子

有没有一种方法可以根据用户角色加载一条路线的不同视图?

如果我想根据角色将主页路径“/”用于不同的视图,是否有一些实现?就像如果您是授权用户,您会看到MainAuth,如果您是访客,您会看到MainGuest?这是一些可以帮助我解释的代码。

const routes = [
  {
    path: '/',
    name: 'main_auth',
    component: MainAuth,
    meta: {
      requiresAuth: true
    }
  },
  {
    path: '/',
    name: 'main_guest',
    component: MainGuest,
    meta: {
      requiresGuest: true
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

对于这个例子,它只加载我声明的第一个路径,无论我是访客还是用户。更具体地说,我在主路径“/”上有一个登录/注册模块,并且我想在登录后在同一路径“/”上加载授权用户页面。

javascript vue.js vue-router vuejs2 vue-cli

5
推荐指数
2
解决办法
4061
查看次数

VueJs - 在 vue.config 中设置多个代理

所以我使用代理进行 API 调用,如下所示:

vue.config.js:

module.exports = {
  devServer: {
    proxy: 'http://www.pathofexile.com/'
  }
}
Run Code Online (Sandbox Code Playgroud)

xxx.vue:

axios.get("http://localhost:8080/api/public-stash-tabs").then..
Run Code Online (Sandbox Code Playgroud)

这有效!现在,当我也想从不同的站点进行 API 调用时,我不知道该怎么做。我想要的是这样的东西:

vue.config.js:

module.exports = {
  devServer: {
    proxy: {
      'http://localhost:8080/one/': {
        target: 'http://www.pathofexile.com/',
        changeOrigin: true
      },
      'http://localhost:8080/two/': {
        target: 'https://api.poe.watch/',
        changeOrigin: true
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

xxx.vue:

axios.get("http://localhost:8080/one/api/public-stash-tabs").then..
axios.get("http://localhost:8080/two/id").then..
Run Code Online (Sandbox Code Playgroud)

但似乎什么也没发生,我收到 404 错误,因为它尝试从 http://localhost:8080/api/public-stash-tabs获取某些内容

我是否走在正确的轨道上,我是否错过了一些东西?或者这不是要走的路?

proxy webpack vue.js webpack-dev-server vue-cli

5
推荐指数
1
解决办法
7767
查看次数

StoryBook React 钩子

因此,我在代码中使用了 useLocation 挂钩,而且我是故事书的新手,我无法找到在代码中初始化该挂钩的方法:

let location = useLocation();

const parsedLocation = new URLSearchParams(location.search)
const query = parsedLocation.get('query')
const {articles, status} = useSearch(query, 50)
Run Code Online (Sandbox Code Playgroud)

故事书中

const Template = (args) => <Page {...args} />;

export const Primary = Template.bind({});
 Primary.args = {
   location: useLocation()
};
Run Code Online (Sandbox Code Playgroud)

// 它向我显示错误,无法读取未定义的属性“位置”

css reactjs react-native storybook

5
推荐指数
1
解决办法
5556
查看次数

角度中的 FormControl 和 AbstractControl 问题

我正在学习在线课程,但遇到很多问题。

我取决于我输入我得到的代码

类型“abstractcontrol”缺少类型“formcontrol”中的以下属性:registerOnChange、registerOnDisable、_applyFormState

或者

Abstractcontrol 类型不可分配给 formcontrol 类型

在我的组件的 TS 中我有

import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import {  FormBuilder, FormGroup } from '@angular/forms';
import { DestinoViaje } from '../models/destino-viaje.model';

@Component({
  selector: 'app-form-destino-viaje',
  templateUrl: './form-destino-viaje.component.html',
  styleUrls: ['./form-destino-viaje.component.css']
})
export class FormDestinoViajeComponent implements OnInit {

  @Output() onItemAdded: EventEmitter<DestinoViaje>;
  fg: FormGroup;

  constructor(fb: FormBuilder) {
    this.onItemAdded = new EventEmitter();
    this.fg = fb.group({
      nombre: [''],
      url: ['']
    });
    console.log(this.fg);

  }

  ngOnInit(): void {


  }

  guardar(nombre: string, url: string): boolean {
    let …
Run Code Online (Sandbox Code Playgroud)

forms form-control angular angular-abstract-control

5
推荐指数
1
解决办法
9170
查看次数

Vuetify 数据表在列上展开行单击

我有一个包含可扩展行的 vuetify 数据表。我与演示的唯一真正区别是,我希望该item.name列能够像 V 形图标一样打开/关闭可扩展行。当我在该列的 v 槽上放置一个@click处理程序时,我收到错误Error in v-on handler: "TypeError: expand is not a function"。这是我需要自定义的唯一列,因此我不想<tr>手动构建整个 v 槽。下面是缩小的代码示例。谢谢。

<v-data-table
    :headers="headers"
    :items="products"
    item-key="productCode"
    show-expand
    :expanded.sync="expanded"
>

  <template v-slot:item.name="{ item, expand, isExpanded }" >
    <h4 class="my-2" @click="expand(!isExpanded)">{{ item.name }} located in {{ item.depot | camelToWords }}</h4>
  </template>

  <template v-slot:expanded-item="{ headers, item }">
    <ProductDetailExpandedRow :currentProduct="item" :headers="headers"/>
  </template>

</v-data-table>

<script>
export default {
  data() {
    return {
      headers: [
        {
          text: 'Name',
          value: 'name', …
Run Code Online (Sandbox Code Playgroud)

html javascript vue.js vuetify.js v-slot

5
推荐指数
1
解决办法
2万
查看次数

Vue.js - 获取 Vuex 模块中的当前路由

我有一个命名空间 vuex 存储,它根据当前路由的参数返回存储的条目。

import Router from '../../router/index'

const options = {
  routeIdentifier: 'stepId'
}

export function fromRoute(state) {
  if (!options.routeIdentifier || !Router.currentRoute.params) {
    return null
  }

  return state.all.find(element => {
    return element.identifier === Router.currentRoute.params[options.routeIdentifier]
  })
}
Run Code Online (Sandbox Code Playgroud)

这对于初始负载来说按预期工作。但是,每当路线发生变化时,它都不会重新加载。

有没有办法在路线改变时重新加载/强制重新计算吸气剂?

javascript vue.js vue-router vuex vuex-modules

5
推荐指数
1
解决办法
4858
查看次数

如何动态改变flutter中stepper的步数?

我正在flutter中以步进器格式制作验证表单。每个步骤都有一个验证表单。

第一次打开页面时,只有一个步骤。我希望用户单击“继续”并再获得一个步进器(即第 2 步并通过在步骤 2 中单击“继续”再获得一个步骤。)

我尝试通过向列表中添加一个步骤并更新调用时间来更改步骤数changeCurrentStepContinue,但它无法增加显示错误的步骤数。一次又一次地前进,我得到了更新的列表。

那么如何通过在每个步骤中单击“继续”来更改同一页面上的步骤数呢?

android dart android-studio flutter

4
推荐指数
1
解决办法
4676
查看次数

Vue 3 + vue-i18n-next:我做错了什么?

我已经开始了一个 Vue 3 项目(目前只不过是一个带有 TypeScript 的样板)并尝试向其中添加 i18n。

据我所知,vue-i18n 在 Vue 3 中不能正常工作;但 vue-i18n-next 应该。

这是我的 main.ts

import { createApp } from "vue";
import "./registerServiceWorker";
import router from "./router";
import store from "./store";
import { createI18n } from 'vue-i18n'
import App from "./App.vue";

//import en from "./locale/en.json"
//import ru from "./locale/ru.json"

const messages = {
    en: {
        message: {
            hello: 'hello world'
        }
    },
    ru: {
        message: {
            hello: '???? ????????????'
        }
    }
}

const i18n = createI18n({
    locale: 'ru',
/* …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-i18n vue-cli vuejs3

4
推荐指数
2
解决办法
5530
查看次数

Vuetify 中展开的 v-data-table 折叠时触发方法

我尝试构建 av-data-table并在观察expanded.sync值时观察到非常奇怪的行为。第1层expanded.sync值看起来正常,但第2层expanded.sync有3个连续相同的记录。

\n

我打算观察这个值,在折叠展开的项目时做一些事情。有没有什么解决方案可以检测展开的项目何时折叠?

\n

顶层代码

\n
<template>\n  <v-data-table\n    :headers="headers"\n    :items="desserts"\n    item-key="name"\n    :expanded.sync="itemExpanded"\n    show-expand>\n  >\n    <template v-slot:top>\n      <v-toolbar height="38" falt color="#cddde1">\n        <v-toolbar-title dense> Test </v-toolbar-title>\n      </v-toolbar>\n    </template>\n      <template v-slot:expanded-item="{headers}">\n        <td :colspan="headers.length">\n          <Show2></Show2>\n        </td> \n      </template>\n  </v-data-table>\n</template>\n<script>\nimport Show2 from "./ShowTest2.vue";\nexport default {\n  name: "Show1",\n   components: {\n      Show2\n  },\n   data: () => ({\n     itemExpanded:[],\n    desserts: [\n      {\n        name: 'Show 1 - item 1',\n        calories: 237,\n        fat: 9.0,\n        carbs: 37,\n        protein: 4.3,\n        iron: '1%',\n      },\n …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-component vuejs2 vuetify.js

4
推荐指数
1
解决办法
3420
查看次数

4
推荐指数
1
解决办法
1410
查看次数