Javascript Meteor和Vue找不到元素:#应用程序
我正在用Meteor和Vue开发一个简单的web应用程序,我遇到了这个问题找不到元素:#app。我搜索了又搜索,为我的问题添加了一些“解决方案”,但仍然没有结果 任务页面.vueJavascript Meteor和Vue找不到元素:#应用程序,javascript,html,node.js,meteor,vue.js,Javascript,Html,Node.js,Meteor,Vue.js,我正在用Meteor和Vue开发一个简单的web应用程序,我遇到了这个问题找不到元素:#app。我搜索了又搜索,为我的问题添加了一些“解决方案”,但仍然没有结果 任务页面.vue <template> <div class="ui center aligned container "> <div class="missionPage"> <h3 class="ui header">Our story</h3>
<template>
<div class="ui center aligned container ">
<div class="missionPage">
<h3 class="ui header">Our story</h3>
<p>{{text1}}</p>
<p>{{text2}}</p>
<h1>Trigger question?</h1>
<a href="#" type="button" id="scrollDownArrow"><i class="huge angle double
down icon" ></i></a>
</div>
</div>
</template>
<script>
import { Session } from 'meteor/session';
export default {
data() {
return {
text1:'abc',
text2:'def'
}
},
}
</script>
在我看来,它似乎没有识别出令人兴奋的应用程序id。我在另一个应用程序中运行了完全相同的代码,它工作得非常完美。我在其他帖子中添加了“window.onload”函数,因为事实证明,该元素无法识别的原因是它没有加载,但错误仍然存在 @RoyJ我不是这么做的吗#应用程序指明了我的“missionPage.vue”将在何处呈现,这是在id为app的div中的“#app”div.Render missionPage.vue中。也许我不明白。这就是我的全部源代码。@RoyJ我该如何从missionPage.html中删除模板标记?我将此页面用作我需要路由到的网站的一部分。我已经设置了一个路由到missionPage模板的路由器,因此删除它将导致页面无法加载。在您的onload函数中,在调用Vue之前,
console.log(document.body.innerHTML)
并查看它是否包含\app
div.@RoyJ。我做了类似的操作:document.addEventListener(“DOMContentLoaded”,函数(事件){console.log(“DOM已完全加载并解析”);然后调用vue,它会显示所有内容都已加载。这并不意味着调用vue时,#app
就在那里,这是您想要知道的。
<template name='missionPage'>
<div id="app">
</div>
</template>
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import { Vue } from 'meteor/akryum:vue';
import missionPage from '/client/template/missionPage.vue';
window.onload=function(){
var app = new Vue({
el: '#app',
render:h=>h(missionPage)
})
}