简体   繁体   中英

Pass prop using router-view and Vue

I have a Laravel Blade page that calls a Vue page using router-view. I have a "test" prop on the Vue page, but the page is not receiving the prop.

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

The code on the Blade page is:

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

There are 2 types of properties: static and dynamic.

  • static: test="some message" (for static values)
  • dynamic: v-bind:test="variable" (for computed values or objects etc.)

In your case, you should use the static one

test="some message"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM