Ruby on rails 获取用于Rails的vue组件样式
我正在尝试在Rails 5应用程序中使用基本模式,但遇到了一些问题 我试图结合的模式是 我的代码如下: javascript/packs/dashboard.jsRuby on rails 获取用于Rails的vue组件样式,ruby-on-rails,vue.js,Ruby On Rails,Vue.js,我正在尝试在Rails 5应用程序中使用基本模式,但遇到了一些问题 我试图结合的模式是 我的代码如下: javascript/packs/dashboard.js import Vue from 'vue/dist/vue.esm' import VueResource from 'vue-resource' import Modal from '../modal.vue' document.addEventListener('DOMContentLoaded', () => { i
import Vue from 'vue/dist/vue.esm'
import VueResource from 'vue-resource'
import Modal from '../modal.vue'
document.addEventListener('DOMContentLoaded', () => {
if(document.getElementById('modal') !== null) {
Vue.component('step-item', {
template: '#modal-template'
})
const modal = new Vue({
el: '#modal',
components: { Modal },
data: { showModal: false }
})
}
})
modal.vue
<template>
<transition name="modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
default header
</slot>
</div>
<div class="modal-body">
<slot name="body">
default body
</slot>
</div>
<div class="modal-footer">
<slot name="footer">
default footer
<button class="modal-default-button" @click="$emit('close')">
OK
</button>
</slot>
</div>
</div>
</div>
</div>
</transition>
</template>
<style scoped>
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
display: table;
transition: opacity .3s ease;
}
.modal-wrapper {
display: table-cell;
vertical-align: middle;
}
.modal-container {
width: 300px;
margin: 0px auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
}
.modal-header h3 {
margin-top: 0;
color: #42b983;
}
.modal-body {
margin: 20px 0;
}
.modal-default-button {
float: right;
}
/*
* The following styles are auto-applied to elements with
* transition="modal" when their visibility is toggled
* by Vue.js.
*
* You can easily play with the modal transition by editing
* these styles.
*/
.modal-enter {
opacity: 0;
}
.modal-leave-active {
opacity: 0;
}
.modal-enter .modal-container,
.modal-leave-active .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
</style>
默认标题
默认主体
默认页脚
好啊
.模态掩码{
位置:固定;
z指数:9998;
排名:0;
左:0;
宽度:100%;
身高:100%;
背景色:rgba(0,0,0,5);
显示:表格;
过渡:不透明度。3s缓解;
}
.模态包装器{
显示:表格单元格;
垂直对齐:中间对齐;
}
.集装箱{
宽度:300px;
保证金:0px自动;
填充:20px 30px;
背景色:#fff;
边界半径:2px;
盒影:0 2px 8px rgba(0,0,0,33);
过渡:全部。3秒轻松;
字体系列:Helvetica、Arial、无衬线字体;
}
.模态头h3{
边际上限:0;
颜色:#42b983;
}
.模态体{
利润率:20px0;
}
.模式默认按钮{
浮动:对;
}
/*
*以下样式将自动应用于具有
*切换其可见性时的transition=“modal”
*由Vue.js编写。
*
*通过编辑,您可以轻松地使用模式转换
*这些款式。
*/
.模态输入{
不透明度:0;
}
.调休有效{
不透明度:0;
}
.modal输入.modal容器,
.modal保持活动状态。modal容器{
-webkit转换:比例(1.1);
转换:比例(1.1);
}
\u modal.html.erb
<div id="modal">
<button type="button" class="btn btn-secondary" id="show-modal" @click="showModal = true">View pictures</button>
<modal v-if="showModal" @close="showModal = false">
<h3 slot="header">custom header</h3>
</modal>
</div>
查看图片
自定义标题
单击该按钮将显示一个模板,但该模板未设置样式。这就好像
标记之间没有任何内容被读取。我是否需要Rails中的插件来加载样式
提前谢谢 如果使用webpacker,则需要在版面中包含样式表\u pack\u标记。如果使用webpacker,则需要在版面中包含样式表\u pack\u标记。这让我抓狂。谢谢我不得不将其命名为javascript_pack_标记,即
stylesheet_pack_标记'application.css'
这让我抓狂。谢谢我必须将其命名为与javascript_pack_标记相同的名称,即stylesheet_pack_标记'application.css'