gpt4 book ai didi

javascript - Aframe + vuejs - 核心 :schema:warn Unknown property `color` for component/system `undefined` . +10ms aframe.js:327

转载 作者:搜寻专家 更新时间:2023-10-30 22:52:01 26 4
gpt4 key购买 nike

我正在尝试让 Aframe 和 vuejs 相互配合良好,但控制台返回警告消息。我猜这是由于 aframe 在 vue 有机会更改它们之前检查了属性值。

警告信息

core:schema:warn Unknown property `color` for component/system `undefined`. +349ms 2aframe.js:327
core:schema:warn Unknown property `color` for component/system `undefined`. +2ms aframe.js:327
core:schema:warn Unknown property `color` for component/system `undefined`. +1ms aframe.js:327
core:schema:warn Unknown property `height` for component/system `undefined`. +1ms aframe.js:327
core:schema:warn Unknown property `color` for component/system `undefined`. +1s aframe.js:327

代码如下:

App.vue

<template>
<a-scene>
<test-component v-for="block in blocks" :color="block.color" :position="block.pos"></test-component>
<a-box :color="color" height="4"></a-box>
<a-entity position="0 0 10" camera look-controls></a-entity>
</a-scene>
</template>

<script>
import TestComponent from './TestComponent.vue';
require('aframe');

export default {
name: 'app',
components:{
TestComponent,
},
data(){
return {
color: 'green',
blocks: [
{color: 'red', pos: "1 0 0"},
{color: 'orange', pos: "2 0 0"},
{color: 'yellow', pos: "3 0 0"}
]
}
},
mounted(){
//test to see if a-frame updates properly
let that = this;
setTimeout(function(){
that.blocks.push({color: 'lime', pos: "4 0 0"})
}, 1000)
setTimeout(function(){
that.blocks[3].pos = "5 0 0"
}, 2000)
}
}
</script>

TestComponent.vue

<template lang="html">
<a-box :color="color" :position="position"></a-box>
</template>

<script>
export default {
props: ['color','position'],
}
</script>

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>aframetest</title>
</head>
<body>
<div id="app"></div>
<script src="dist/build.js"></script>
</body>
</html>

ma​​in.js

import Vue from 'vue'
import App from './App.vue'

new Vue({
el: '#app',
render: h => h(App)
})

最佳答案

具有更简单设置的工作代码:
(vuejs 2.4.4 + 框架 0.6.1)

https://jsfiddle.net/jg6uhh21/

html:

<a-scene id="app">
<test-component v-for="block in blocks" :color="block.color" :position="block.pos"></test-component>
<a-entity position="0 0 10" camera look-controls></a-entity>
</a-scene>

JavaScript:

Vue.component('test-component', {
props: ['color','position'],
template: `<a-box :color="color" :position="position"></a-box>`
})
new Vue({
el: '#app',
data(){
return {
blocks: [
{color: 'red', pos: "1 0 0"},
{color: 'orange', pos: "2 0 0"},
{color: 'yellow', pos: "3 0 0"}
]
}
},
mounted(){
setTimeout(() => {
this.blocks.push({color: 'lime', pos: "4 0 0"})
}, 1000)
setTimeout(() =>{
this.blocks[3].pos = "5 0 0"
}, 2000)
}
})

我以相同的方式结合 vue.js 和 aframe 构建的小型交互式演示:
https://rawgit.com/frederic-schwarz/aframe-vuejs-3dio/master/index.html https://github.com/frederic-schwarz/aframe-vuejs-3dio/blob/master/index.html

关于javascript - Aframe + vuejs - 核心 :schema:warn Unknown property `color` for component/system `undefined` . +10ms aframe.js:327,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40933670/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com