我想知道为什么我会因为这个简单的代码而收到警告和错误。我正在使用vue模板。这是我的第一个Vue应用程序,因此请提供更多细节,以便我继续学习。
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'props' of undefined"
found in
---> <App> at src/App.vue
<Root>
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'props' of undefined
at normalizeProps (vue.runtime.esm.js?2b0e:1419)
at mergeOptions (vue.runtime.esm.js?2b0e:1521)
at mergeOptions (vue.runtime.esm.js?2b0e:1535)
at Function.Vue.extend (vue.runtime.esm.js?2b0e:5153)
at createComponent (vue.runtime.esm.js?2b0e:3184)
at _createElement (vue.runtime.esm.js?2b0e:3416)
at createElement (vue.runtime.esm.js?2b0e:3353)
at vm._c (vue.runtime.esm.js?2b0e:3485)
at Proxy.render (eval at ./node_modules...
这是孩子的嘴巴
Animakit.vue
<template>
<div id="Animakit">
In Animakit
</div>
</template>
<script>
import firstOne from '../animakit.js'
export default {
name: 'Animakit',
mixins: [firstOne],
mounted: function () { this.firstOne() }
}
</script>
这是主要的App vue
App.vue
<template>
<div id="app">
<Animakit></Animakit>
<div>hello in App.vue </div>
</div>
</template>
<script>
import Animakit from './components/Animakit.vue'
export default {
components: {
'Animakit': Animakit
}
}
</script>
这是App vue的使用方式。
main.js
import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
import axios from 'axios';
import App from './App.vue';
const http = axios.create({
baseURL: process.env.BACKEND_URL ? process.env.BACKEND_URL : 'http://localhost/todos',
});
Vue.prototype.$http = http;
Vue.use(BootstrapVue);
Vue.config.productionTip = false;
new Vue({
render: (h) => h(App),
}).$mount('#app');
JavaScript文件的内容 animakit.js
function firstOne() {
}
export default firstOne;
答案 0 :(得分:1)
Mixin配置与组件配置非常相似。要创建名为SELECT TOWER.EDI_NAME_TOWER AS "DEPARTMENT NAME",
COUNT(DEPARTAMENT.NRO_DEPARTAMENT) AS "TOTAL DEPARTMENTS"
FROM DEPARTAMENT
JOIN TOWER
ON DEPARTAMENT.ID_TOWER= TOWER.ID_TOWER
GROUP BY TOWER.EDI_NAME_TOWER;
的方法,您需要执行以下操作:
firstOne
Vue将自动将mixin配置合并到组件的配置中。官方文档https://vuejs.org/v2/guide/mixins.html#Option-Merging中有更多相关内容。