반응형
수집되지 않은 참조 오류:Index.html에 vue 설정을 넣을 때 Vue가 정의되지 않음
나는 최근에 에 대해 배웠다.vue
나는 이 파일을 가지고 있다.main.js
import Vue from 'vue/dist/vue.js'
import Buefy from 'buefy'
import 'buefy/lib/buefy.css'
Vue.use(Buefy)
var App = new Vue({
el: '#app',
data: {
message : "It's working"
}
})
그리고 여기 내 html이 있다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue Example</title>
</head>
<body>
<h3 id="app">{{ message }}</h3>
<script src="dist/build.js"></script>
<script>
</script>
</body>
</html>
그건 효과가 있다.근데 지금 대본으로 뭔가를 하려고 해요.나는 변한다main.js
(사용하고 있습니다.webpack
)
import Vue from 'vue/dist/vue.js'
import Buefy from 'buefy'
import 'buefy/lib/buefy.css'
Vue.use(Buefy)
그러면 내 인덱스.이것에 추가.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue Example</title>
</head>
<body>
<h3 id="app">{{ message }}</h3>
<script src="dist/build.js"></script>
<script>
var App = new Vue({
el: '#app',
data: {
message:"It's not working"
}
})
</script>
</body>
</html>
그리고 나는 이 오류를 받는다.
수집되지 않은 참조 오류:Vue가 정의되지 않았습니다.
어떻게 하면 고칠 수 있을까요?
의 새로운 인스턴스를 작성하려면Vue
직접 에index.html
당신은 도서관에 포함하거나 둘 중 하나여야 합니다.index.html
:
<script src="https://unpkg.com/vue@2.4.2"></script>
또는 를 할당해야 합니다.Vue
로.window
에 반대하다.main.js
다음과 같이 합니다.
main.filename:
import Vue from 'vue';
window.Vue = Vue;
그리고 나서index.html
에 액세스 할 수 있습니다.Vue()
왜냐하면 그것은 전지구적 특성이기 때문이다.window
물건.
언급URL : https://stackoverflow.com/questions/45388795/uncaught-referenceerror-vue-is-not-defined-when-put-vue-setting-in-index-html
반응형
'itsource' 카테고리의 다른 글
Vuex Getter Hook(파라암 포함) (0) | 2022.08.15 |
---|---|
Vuetify v-tabs v-tab 항목 오버플로 창 너비 (0) | 2022.08.15 |
vuex 스토어에서 JSON 데이터를 사용하는 방법(웹 팩 없음) (0) | 2022.08.15 |
Android 애플리케이션의 빌드/버전 번호는 어떻게 얻을 수 있습니까? (0) | 2022.08.15 |
visual studio 2017 스파 템플릿 vue js 누락 (0) | 2022.08.15 |