django - Vue 代码未在我的 Django/Vue 项目中更新
问题描述
我使用本指南将 VueJS 添加到我的 Django 项目中。
我现在正在尝试将示例更改为我制作的一些代码,但没有任何变化: assets/js/components/Demo.vue
<template>
<div>
<p>This is just a Demo.</p>
</div>
</template>
<script>
</script>
<style>
</style>
例如,如果我将此代码更改为:
<template>
<div>
<h1> test </h1>
<p>TEST.</p>
</div>
</template>
<script>
</script>
<style>
</style>
我将继续在我的前端看到第一段代码。
这是我的index.js
window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');
import Vue from 'vue';
import Demo from "./components/Demo.vue";
window.Vue = Vue;
const app = new Vue({
el: '#app',
components: {
Demo
}
});
这是我的 Django 模板,从中调用了 Vue:
{% load render_bundle from webpack_loader %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Django Vue</title>
</head>
<body>
<h1>test</h1>
<div id="app">
<demo></demo>
</div>
{% render_bundle 'main' %}
</body>
</html>
我的 Vue/JS 代码的其他部分与这个存储库基本相同,因为我遵循了指南https://github.com/michaelbukachi/django-vuejs-tutorial
我的控制台中是否遗漏了一些东西,也许?我应该以某种方式更新我的 JS/Vue 代码吗?任何帮助表示赞赏,在此先感谢!
解决方案
试着做
const app = new Vue({
render: (h) => h(Demo)
});
app.$mount('#app')
和改变
<div id="app">
<demo></demo>
</div>
至<div id="app"></div>
推荐阅读
- python - Celery SQS 任务失败后不会执行
- php - 由于奇怪的版本错误,无法在 macOS Catalina 上安装 PHP 7.3
- html - 通过 p 标签中的 xslt i 标签将 xml 转换为 html
- python - 无法使用 openpyxl 写入输出 excel 文件
- elasticsearch - 如何从 ElasticSearch 中检索脚本字段以及其他字段
- java - 如何通过路径在 LibGDX 中绘制自定义形状?
- c - 尝试拆分字符串并将它们放入数组时收到错误消息
- java - 如何通过 Android 应用程序发出 HTTP 请求
- token - Instagram 令牌在一些请求后被阻止
- java - Querydsl 本机 jpa 查询返回实体而不是对象数组