最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use Vue3 via CDN on Django without NodeJs bundler? - Stack Overflow

programmeradmin9浏览0评论

On Vue2 I just add the CDN then I have Vue available on my js files, but Vue3 I could not do the same - My js files does not detect Vue. How can I solve it in order to use Vue3?

On Vue2 I just add the CDN then I have Vue available on my js files, but Vue3 I could not do the same - My js files does not detect Vue. How can I solve it in order to use Vue3?

Share Improve this question edited Aug 6, 2020 at 15:16 Boussadjra Brahim 1 asked Aug 6, 2020 at 15:02 Thiago AraujoThiago Araujo 1893 silver badges15 bronze badges 3
  • use cdn to load vue.js – Harish Mahamure Commented Aug 6, 2020 at 15:05
  • 1 @Thiago I'v got an example fiddle here jsfiddle/dapo/Ly0zdcb4 seems to be working fine. Can you clarify what issue you're having? – Daniel Commented Aug 7, 2020 at 15:36
  • @Daniel, follow the the link to the git repository working on Django with Vue2: github./u7540936/ToDoApp_Django_Vue2. In Static > vue_axios folder, I have vue.js (Vue2), axios and the the "Main.js". Probably it is some simple different from Vue2 I did not figure out yet. – Thiago Araujo Commented Aug 7, 2020 at 16:59
Add a ment  | 

2 Answers 2

Reset to default 9

You will need to include the new vue js file

You can get source from here https://unpkg./[email protected]/dist/vue.global.js and link or include in your project

I cut out some stuff (axios, methods, template, etc.) But this should give you an idea.

The important parts...

  • use createApp from Vue either using Vue.createApp or using destructuring
  • data needs to be a function that returns an object

Example:

const app = Vue.createApp({
  el: '#app',
  delimiters: ['[[', ']]'],
  data() {
    return {
      returned_task: '',
      new_task: '',
      create_modify: '',
      modify_id: -1,
      modify_index: -1,
      tasks: []
    }
  },
  created() {
    this.tasks = ['do this 
发布评论

评论列表(0)

  1. 暂无评论