我正在尝试设置基本的原型网页来测试代码中的UX设计。并且想要回收html文件,比如左导航。尝试使用Vue来做这件事,这样我也可以学习Vue。我没有访问artifactory (公司政策)的权限。所以除了我找到的这个http vue加载程序包之外,我不能使用其他东西。到目前为止,我能够添加外部vue,即comp-nav。但在这里,我想将title=“服务”从index.html传递给comp-vue。我该怎么做?任何帮助都是最好的!顺便说一句,使用mac自带的Apache2运行。
index.html
<!DOCTYPE html>
<html lang="en">
<title>App</title>
<!-- Vue2 -->
<!-- from https://github.com/FranckFreiburger/http-vue-loader -->
<head>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/http-vue-loader"></script>
</head>
<body>
<div id="app">
<comp-nav title="Service"></comp-nav>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
components: {
'comp-nav': httpVueLoader('components/comp-nav.vue')
}
});
</script>
</body>
</html>组件/comp-nav.vue
<template>
<div id="nav">
<div class="nav-header">
<div class="header-title"><a>{{ title }}</a></div>
<div class="header-close">U</div>
</div>
<div class="nav-body">
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</div>
</div><!-- #nav -->
</template>发布于 2021-04-04 12:26:19
基于example from the docs,您可以在comp-nav.vue中使用define a component prop
<template>
<div class="header-title">{{ title }}</div>
</template>
<script>
module.exports = {
props: ['title']
}
</script>https://stackoverflow.com/questions/66936418
复制相似问题