Created
May 8, 2020 09:59
-
-
Save xchao0213/9293a5d3e6fbeaf661e6bcd94d3d2abd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import xImg from './components/x-img'; | |
import xText from './components/x-text'; | |
Vue.config.productionTip = true; | |
const Engine = { | |
name: 'engine', | |
components: {}, | |
methods: { | |
renderContent(h, element) { | |
return ( | |
<div> | |
{h(element.name, element.value)} | |
</div> | |
); | |
} | |
}, | |
render(h) { | |
const { contents } = window.page; | |
return ( | |
<div> { | |
contents.map((ele) => { | |
return ( | |
<div> | |
{ this.renderContent(h, ele) } | |
</div> | |
); | |
}) | |
} | |
</div> | |
); | |
} | |
}; | |
Vue.component(Engine.name, Engine); | |
Vue.component(xImg, xImg); | |
Vue.component(xText, xText); | |
export default { | |
Engine | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<title><%= page.name %></title> | |
</head> | |
<body> | |
<%- include('header'); -%> | |
<h1> | |
Title | |
</h1> | |
<div id="app"> | |
<engine /> | |
</div> | |
<%- include('footer'); -%> | |
<script src="/libs/vue.min.js"></script> | |
<script>window.page = <%- JSON.stringify(page) %></script> | |
<script src="/engine/engine.umd.min.js"></script> | |
<script> | |
// Vue.component('engine', window.Engine) | |
new Vue({ | |
el: '#app', | |
data: {}, | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment