Answer the question
In order to leave comments, you need to log in
How to add a component to Vue Router?
I am working on a Django web application, I connected Vue.js to the templates. In this case, a single-page application, when you click on the button, the page content should change. The documentation states that you can specify a file as a template. Is it possible to specify an html file so that when the button is clicked, the contents of the html file are rendered, if so, how can this be done?
Answer the question
In order to leave comments, you need to log in
1. First you need to install html-loader
and configure Webpack:
yarn add html-loader | npm install html-loader
{
test: /\.(html)$/,
exclude: /(node_modules)/,
use: {
loader: "html-loader"
}
}
.html
the file into the router.import Destination from '/path/to/destination.html'
.html
file as a template.{
path: '/destination',
mode: history,
name: 'destination',
component: { template: Destination }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question