Vue 2.0 Hello World
by superj80820
HTML
<script src="https://unpkg.com/vue"></script>
<div id="app" class="asdf">
<p>{{ message }}
<img src="https://imgur.com/cKgyQ5Y.jpg" />
</p>
</div>
JavaScript
function addStyle(css) {
const head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
if (style.styleSheet){
// This is required for IE8 and below.
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
}
})
addStyle(`
.asdf img {
max-width: 100%;
height: auto;
}`)