[Vuejs]-Connecting html pages to vue page

3👍

It is better and easier to just transform the static HTML page into a component by simply creating a component and copy pasting the static HTML code inside the component template however if you insist on importing the file as HTML format you might need to install a package called html-loader with :

yarn add html-loader | npm install html-loader

Then you need to update your webpack.config.js file with :

{
   test: /\.(html)$/,
   exclude: /(node_modules)/,
   use: {
   oader: "html-loader"
   }
}

Then you import the HTML file with :

 import FileName from '/path/to/yourFilePath.html'

And finally you nest the template inside your router config :

 {
  path: '/path',
  name: 'routeName',
  component: { template: FileName}
}

Leave a comment