Demo for Quick example / vue-bem-cn - Simple BEM class name generator for Vue.JS
Created
February 21, 2017 00:27
-
-
Save anonymous/0474b93c9f9ad8f06b3f227ebc8532ee to your computer and use it in GitHub Desktop.
Quick example / vue-bem-cn
This file contains hidden or 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
<div id="app"></div> | |
<script type="text/x-template" id="example"> | |
<div> | |
<textarea v-model="test" rows="10" style="width: 900px"> | |
</textarea> | |
<textarea v-model="comp" rows="10" style="width: 900px"> | |
</textarea> | |
<div> | |
</script> | |
<script type="text/x-template" id="btn"> | |
<button :class="b({size, theme})" :type="type"> | |
<span :class="b('text')"> | |
<i v-if="icon" :class="b('icon', { icon })"></i> | |
{{b({size, theme})}} | |
<slot></slot> | |
</span> | |
</button> | |
</script> | |
<script type="text/x-template"> | |
<div class="example"> | |
<btn type="button" class="mix-any-class" size="large" theme="island" icon="star"> I'am BEM button! </btn> | |
</div> | |
</script> | |
This file contains hidden or 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
Vue.use(vueBemCn.default); | |
Vue.component('btn', { | |
data() { | |
return { | |
templ: null | |
} | |
}, | |
template:"#btn", | |
props: ['size', 'theme', 'type', 'icon'], | |
}) | |
Vue.component('test', { | |
props: ['tmpl', 'lol'], | |
//render: Vue.compile('<div v-html="tmpl"></div>').render, | |
// watch: { | |
// tmpl() { | |
// // this.$forceUpdate() | |
// } | |
// } | |
}) | |
Vue.component('app', { | |
template: "#example", | |
data() { | |
return { test: '<h1 class="comp">Heelo</h1>', comp: null} | |
}, | |
watch: { | |
test() { | |
let compile = Vue.compile(this.test); | |
var a = new Vue({ | |
name: 'block', | |
render: compile.render, | |
staticRenderFns: compile.staticRenderFns, | |
}); | |
a.$mount() | |
console.dir(a.$el); | |
this.comp = a.$el.outerHTML; | |
} | |
} | |
}); | |
const vm = new Vue({ | |
el: "#app", | |
render: h => h('app'), | |
}); |
This file contains hidden or 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
<script src="http://vue-bem-cn.surge.sh/vue-bem-cn.umd.js"></script> | |
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment