从Vue.js中的index.html调用组件
在我的应用程序中,没有分配给从Vue.js中的index.html调用组件,vue.js,components,Vue.js,Components,在我的应用程序中,没有分配给#app元素的app.vue组件。相反,在我的index.html中,我有一个元素,默认情况下显示一些Home.vue组件,或者根据路由显示任何其他组件 但是,我希望始终显示某个组件(通知用户联机状态),而不考虑当前路由。但是,如果无法从index.html调用组件,如何实现这一点?还是有可能 index.html: <!DOCTYPE html> <html lang="en"> <head><meta charset=
#app
元素的app.vue
组件。相反,在我的index.html
中,我有一个
元素,默认情况下显示一些Home.vue
组件,或者根据路由显示任何其他组件
但是,我希望始终显示某个组件(通知用户联机状态),而不考虑当前路由。但是,如果无法从index.html调用组件,如何实现这一点?还是有可能
index.html:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"></head>
<body>
<div id="app">
<!-- Component handling user status (connected / not connected) would go here -->
<router-view></router-view>
</div>
<script src="dist/build.js"></script>
</body>
</html>
将您的组件放在
上方(注释指示
):
您能否在中提供一个示例?
<div id="app">
<user-presence-status></user-presence-status>
<router-view></router-view>
</div>
import UserPresenceStatus from '@/components/UserPresenceStatus';
new Vue({
el: '#app',
compnents: {
UserPresenceStatus
}
);