我使用vue
,使用cdn
链接,并像这样使用我的组件。
Vue.component('forward-button', {
template: `
<button type=button class="btn btn-default" @click="goURL">{{this.title}}</button>
`,
props: ['url', 'title'],
methods: {
goURL: function() {
console.log(this.url);
window.open(this.url);
}
}
});
new Vue({
el: '#app',
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id='app'>
<forward-button title="google" url="#"></forward-button>
</div>
如何将其设置为单个文件组件的样式?不想在HTML
中使用样式
通过cdn链接使用vue时,不能使用单个文件组件。
您可以像使用常规网站一样,使用在HTML文件的<head>
导入的CSS文件。