我正在使用VueJS 2.3.3和coffescript,我正在尝试将道具传递给路由器中的组件,但我没有成功。代码不是我的,所以我在弄清楚我做错了什么时遇到了一些麻烦。这是我的路由器:
App = require './views/App'
Shared = {
header: require('./views/shared/header'),
global_loader: require('./views/shared/global_loader.vue')
}
view = (view_name) ->
require("./views/#{view_name}")
componentize = (view_name, options = {}) ->
options.include_header ?= true
component = options.component || {}
component.app ?= view(view_name)
component.header = Shared.header if options.include_header
component
exports.routes = [
{
path: '/',
component: App
children: [
{
path: '/component',
components: componentize('path/to/component'),
props: { has_groups: true }
},
...
]
}
...
}
这是我的App.vue代码:
<template lang="pug">
#app-wrapper
transition(name="fade")
router-view(name="global_loader")
#header-wrapper
router-view(name="header")
#current-view-wrapper.container
transition(name="enter")
router-view(name="app")
</template>
在我的组件上,我像往常一样收到道具:
props:
has_groups:
default: false
除了has_groups没有从路由器接收到正确的prop值之外,一切正常。它没有改变为真。
任何人都可以帮我找到我错过的东西吗?
答案 0 :(得分:1)
我找到了解决方案。当我使用命名路由时,我必须配置道具,如:
FILE *f, *g
f = open("alumnos.txt", "r"); // opens your main file
g = open("temp.txt", "w"); //opens your temporary file
.
. Copy from alumnos to temp and change the things you want to
.
fclose(f)
fclose(g)
remove("alumnos.txt") // old file without the changes
rename("temp.txt", "alumnos.txt") // renaming the new file with the changes