【问题标题】:Pass prop using router-view and Vue使用 router-view 和 Vue 传递 prop
【发布时间】:2018-11-16 21:36:01
【问题描述】:

我有一个使用路由器视图调用 Vue 页面的 Laravel Blade 页面。我在 Vue 页面上有一个“测试”道具,但该页面没有收到该道具。

const routes = [
    {path: '/:test', component: MainPageIndex, name: 'mainPageIndex', props: true}
];

刀片页面上的代码是:

<router-view name="mainPageIndex" :test="Test message"> </router-view>
<router-view :test="Test message"> </router-view>

【问题讨论】:

  • 你在 Vue 组件上声明了 test 属性吗?
  • 是的,当然,它已经声明了。
  • 你试过test="Test Message"而不是:test="Test message"吗?
  • 谢谢!它现在工作了。

标签: laravel vue.js vuejs2 vue-router


【解决方案1】:

有两种类型的属性:静态和动态。

  • static: test="some message"(用于静态值)
  • 动态:v-bind:test="variable"(用于计算值或对象等)

在你的情况下,你应该使用静态的

test="some message"

【讨论】:

  • 与其说是静态与动态,不如说是字符串与 javascript 表达式。
猜你喜欢
  • 2018-05-20
  • 2021-08-26
  • 1970-01-01
  • 2017-12-13
  • 2021-10-16
  • 2018-08-04
  • 2021-05-26
  • 2019-07-02
  • 2017-03-14
相关资源
最近更新 更多