https://github.com/kikyous/sprockets-vue
可以在 rails 项目中直接使用.vue 文件,不用 vue-loader, webpack 什么的,直接和 Rails Asset Pipeline 结合
VCompents[filename]
里面index.vue
//= require compents/card
<script lang="coffee">
{
data: ->
search: ''
members: []
components:
card: VCompents['compents/card']
methods:
clear: ->
this.search = ''
}
</script>
<template>
<div class="container">
<div class='search icon-input'>
<span class="search-icon glyphicon glyphicon-search"></span>
<input class="form-control" type="text" v-model='search'>
<span @user1='clear' class="clear-icon glyphicon glyphicon-remove"></span>
</div>
<card v-for="m in members" :m='m'></card>
</div>
</template>
<style lang="scss">
@import "bootstrap-sprockets";
@import "bootstrap/variables";
@import "bootstrap/mixins";
// Reset and dependencies
@import "bootstrap/normalize";
@import "bootstrap/glyphicons";
// Core CSS
@import "bootstrap/scaffolding";
@import "bootstrap/code";
@import "bootstrap/forms";
@import "bootstrap/media";
@import "bootstrap/list-group";
@import "bootstrap/panels";
@import "bootstrap/utilities";
}
</style>
application.coffee
#= require index
new Vue(
el: '#search',
components: {
'index': VCompents.index
}
)
application.scss
//=require index