Demo for Quick example / vue-bem-cn - Simple BEM class name generator for Vue.JS
-
-
Save c01nd01r/9d08340b452211b1c99cc5ea644e73f7 to your computer and use it in GitHub Desktop.
Quick example / vue-bem-cn
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
<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 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 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/vue@2.1.10/dist/vue.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment