javascript - Django + Vue.js 导入模块

标签 javascript html django vue.js ckeditor

如何在由 Django 呈现的模板中导入 VueJS 应用程序的模块。我正在尝试导入模块 CKEditor。
这是我的情况:

template.html:

<div id="app">
    <form>
        <vue-ckeditor v-model="formField" />
    </form>
</div>
<script src="https://unpkg.com/vue-ckeditor2"></script>
<script>
Vue.component('vue-ckeditor', VueCkeditor.VueCkeditor)
var app = new Vue({
    delimiters: ['[[', ']]'],
    el: '#app',
    data: function() {
        return {
            formField: "",
        }
    },
</script>

关于 Github它需要 import VueCkeditor from 'vue-ckeditor2';

有没有办法在 Django 模板中做到这一点?

最佳答案

我的理解是您想导入一个组件并在您的模板中使用它。

试试这个:-

var VueCkeditor  = require(vue-ckeditor2);

    var app = new Vue({
         components: { VueCkeditor : VueCkeditor },
        delimiters: ['[[', ']]'],
        el: '#app',
        data: function() {
            return {
                formField: "",
            }
        },
    </script>

编辑:- 试试这个:-

 <script src="https://unpkg.com/vue-ckeditor2@2.0.7/dist/vue-ckeditor2.js"></script>
 var app = new Vue({
// the component is exported inside defult 
components: { VueCkeditor : VueCkeditor.default },
        delimiters: ['[[', ']]'],
        el: '#app',
        data: function() {
            return {
                formField: "",
            }
        },
    </script>

关于javascript - Django + Vue.js 导入模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51925617/

相关文章:

html - 如何根据所选选项的高度调整选择菜单的大小?

javascript - 为什么使用 switchMap 时无法访问属性?

javascript - Node.js 中的语法错误 : Unexpected end of input at Module. _compile

php - 使用 PHP 从 SQL 查询创建 HTML 表,没有重复的行?

javascript - 根据光标位置执行不同的功能(javascript)

python - django 通过 Node 服务器和 socket.io 将消息保存到数据库

python - 当 Django 中加载所有 url 时发出信号

javascript - 您可以使用 Django 框架将 Python 用于前端和后端吗?

javascript - 什么会影响 Ajax 调用的速度?

javascript - d3js SVG :title tooltip doesn't show up