Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

vue 运行报错 createApp.use is not a function

我的 main.js 代码如下:

import { createApp } from 'vue'
import App from './App.vue'

import VueLazyload from 'vue-lazyload' // 引入这个懒加载插件

// 或者添加 VueLazyload 选项
createApp.use(VueLazyload, {
  preLoad: 1.3,
  error: 'dist/error.png',
  loading: 'dist/loading.gif',
  attempt: 1
})

createApp(App).mount('#app')

但是在运行的时候报错,如图:

image.png

请问是为什么呢?求教!

我的版本如下:
@vue/cli 4.4.6
webpack-cli 4.2.0
webpack 4.44.1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

@vue/cli 4.4.6 是 vue2 的版本,createApp 是 vue3 的方法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...