简体   繁体   English

如何使用 Vue 为两个 HTML 页面构建文件?

[英]How to build files for two HTML pages using Vue?

Right now, I have two HTML files I want to build.现在,我有两个要构建的 HTML 文件。 My project structure is like so.我的项目结构是这样的。

|- node_modules
|- public
|  |- blog
|  |  |- some-page.html
|  |- index.html
|- src (contains all the Vue components)
   |- Blog.Vue
   |- Index.Vue
   |- main.js

In my some-page.html , I have a div with the ID blog and in my index.html file, I have a div with the ID app .在我的some-page.html中,我有一个 ID 为blogdiv ,在我的index.html文件中,我有一个 ID 为appdiv Then, in my main.js , I have this code.然后,在我的main.js中,我有这段代码。

import Vue from 'vue';
import Index from './Index.vue';
import Blog from './Blog.vue';
import vuetify from './plugins/vuetify';

Vue.config.productionTip = false;

new Vue({
  vuetify,
  render: (h) => h(Index),
}).$mount('#app');

new Vue({
  vuetify,
  render: (h) => h(Blog),
}).$mount('#blog');

When I build the project, the some-page.html doesn't get updated at all.当我构建项目时, some-page.html根本没有得到更新。 The index.html page works fine. index.html页面工作正常。 How can I make it so when I build the project, the some-page.html is also injected with the Vue component?我怎样才能做到这一点,当我构建项目时, some-page.html也注入了 Vue 组件? I want to upload the built files to my server for hosting for my personal experimentation of using Vue.我想将构建的文件上传到我的服务器以托管我个人使用 Vue 的实验。

I have the source code published on Github here: https://github.com/171112542/seo我在 Github 上发布了源代码: https://github.com/171112542/seo

As you are using Vue CLI, you can use it's "multi-page mode" configurable with the pages config当您使用 Vue CLI 时,您可以使用它的“多页面模式”,可通过页面配置进行配置

Note that each html template should have it's own separate main.js entry point请注意,每个html模板都应该有自己独立的main.js入口点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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