Vuejs가 mixin에서 속성을 읽지 않음 및 내보내기 NOT FOUND 오류입니다.
이 에러는 3일간 발생하고 있습니다만, 이것이 버그인지 아닌지는 알 수 없습니다만, vuejs/vue-cli 로부터 vuejs 를 인스톨 했습니다.
다음의 순서에 따릅니다.
npm install -g vue-cli
vue init webpack foo.com
cd foo.com
npm install
npm run dev
지금까지는 이렇게 디렉토리 구조를 작성했습니다.src/
— src
— assets
— filters
— config
— components
Profiles.vue
Login.vue
profiles.js
routes.js
main.js
그래서...routes.js
이런 게 있어요.
// routes.js
import ProfilesView from './components/Profiles.vue'
import LoginView from './components/Login.vue'
const routes = [{
path: '/profiles',
component: ProfilesView
},
{
path: '/login',
component: LogoutView
}]
export default routes
현재까지는 위의 코드에 문제가 없습니다.문제는 아래의 두 파일에서도 발생합니다.profiles.js
또는Profiles.vue
여기 profiles.js가 있습니다.
const profiles = Vue.mixin({
data: function () {
return { profiles: [] }
},
methods: {
fetchProfiles: function(){....},
mounted: function(){ this.fetchProfiles() }
})
export default profiles
여기 프로파일이 있습니다.표시하다
<template lang="html">
<div> {{ profiles }}<div>
</template>
<script>
import { profiles } from '../../profiles'
export default {
mixins: [profiles],
data () {
return { profiles: [] }
},
mounted () {}
}
</script>
<style lang="css">
</style>
위의 코드에서는, 이러한 에러가 발생합니다.
profiles.js:1 Uncaught ReferenceError: Vue is not defined
at Object.<anonymous> (profiles.js:1)
at __webpack_require__ (bootstrap 1995fd0fa58cb1432d6f:659)
at fn (bootstrap 1995fd0fa58cb1432d6f:85)
at Object.defineProperty.value (app.js:55806)
at __webpack_require__ (bootstrap 1995fd0fa58cb1432d6f:659)
at fn (bootstrap 1995fd0fa58cb1432d6f:85)
at Object.<anonymous> (Profiles.vue:7)
at __webpack_require__ (bootstrap 1995fd0fa58cb1432d6f:659)
at fn (bootstrap 1995fd0fa58cb1432d6f:85)
at Object.__webpack_exports__.a (app.js:56033)
덧붙이면import Vue from 'vue'
로.profiles.js
위의 오류는 다음 오류로 대체됩니다.
Uncaught TypeError: Cannot read property 'components' of undefined
at checkComponents (vue.esm.js:1282)
at mergeOptions (vue.esm.js:1363)
at mergeOptions (vue.esm.js:1379)
at Function.Vue.extend (vue.esm.js:4401)
at Object.exports.createRecord (index.js:47)
at Profiles.vue:26
at Object.<anonymous> (Profiles.vue:30)
at __webpack_require__ (bootstrap 625917526b6fc2d04149:659)
at fn (bootstrap 625917526b6fc2d04149:85)
at Object.__webpack_exports__.a (app.js:56036)
이것은 에 대한 불만입니다.mixins: [profiles],
에profiles.js
,나는 생각하고 있다.profiles
prop는 정의되어 있지 않지만 그렇지 않습니다.웬일인지 그래.Profiles.vue
올바른 데이터를 읽거나 읽지 않음profiles.js
항상 다음 에러가 발생하기 때문입니다.
[HMR] bundle has 1 warnings
client.js:161 ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/Profiles.vue
6:11-15 "export 'profiles' was not found in '../../profiles'
불평하고 있다export default profiles
에 없습니다.profiles.js
분명히 그렇긴 하지만요require를 사용하여 경로 변경도 시도했습니다.전부다.아무것도 안 돼.
이 건에 대해 어떤 도움이라도 주시면 감사하겠습니다.
Import 중profiles.js
잘못된 방법으로:
import { profiles } from '../../profiles'
사용하고 계시기 때문에export default
,그럴 것 같네요.
import profiles from '../../profiles'
언급URL : https://stackoverflow.com/questions/45878277/vuejs-not-reading-property-from-mixins-and-export-not-found-error
'it-source' 카테고리의 다른 글
DOM 엘리먼트를 삭제했을 경우, 그 리스너도 메모리에서 삭제됩니까? (0) | 2022.11.19 |
---|---|
jQuery를 사용하여 JavaScript 개체에서 선택한 항목에 옵션을 추가하는 가장 좋은 방법은 무엇입니까? (0) | 2022.11.19 |
이름이 없는 Java 메서드 호출 (0) | 2022.11.19 |
MySQL에서 필드가 null인 경우 0을 반환합니다. (0) | 2022.11.19 |
mariadb 노드 사용여러 쿼리를 사용하는 JS 커넥터 (0) | 2022.11.01 |