我正在尝试构建一个应用程序,将use节点用作后端,将ejs作为模板引擎,将Vue作为前端框架,因此express是指向页面和index.ejs页面的路由器。我将脚本阶段包括到js页面中,该页面在main.js
中加载以下命令 import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
render: h => h(App)
})
因此,这需要将vue组件呈现到div标签中,该标签具有一个ID为app.app.vue的应用
<template>
<h2>this is a template {{ title }}</h2>
</template>
<script>
export default {
data () {
return {
title : 'shaked Vue',
name : "shaked",
ninjasx : [
{
name : "sjdhajs",
showMe : false,
mess : "we all have secreate"
} ,
{
name : "shakex",
showMe : false,
mess : "we all black"
} ,
{
name : "chxn",
showMe : false,
mess : "we all mr chen"
}
]
}
} ,
methods:{
greet(){
return 'hello world'
} ,
updateT(title){
this.title = title.split("").reverse().join("")
}
}
}
</script>
<style scoped>
h1{
color: red;
}
</style>
和快速应用看起来像这样
app.get('/' , function (req , res) {
res.render('index', {data : "this is working"});
});
和类似的ejs文件
<div id='app'></div>
<h1> <%= data %> </h1>
无论我尝试什么,我都无法使它起作用,因为开始时说import Vue from 'vue'
中存在语法错误。我需要两个部分的连接帮助。我做了一些Vue作为前端而Node作为后端的工作,但是我无法将它们结合在一起。