Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

css 白线

Posted on 2017-07-17 15:58

rails sql 多表联查

Posted on 2017-07-14 17:05

俩表联查(A中有B的外键)

1
A.joins(:B)

三表联查
1)如果A中有B和C的外键

1
A.joins(:B, :C)

2)如果A中有B的外键,B中有C的外键

1
A.joins(B: :C)

js--字符串包含

Posted on 2017-07-12 16:34

indexOf用法:

if (route.indexOf(“repaire_staffs”) != -1){
document.title = “维修人员”
}

用 -1这个值来判断 不包含就会返回-1

微信小程序

Posted on 2017-07-07 14:55

官方文档
wxml
1.不用div标签 用代替

2.条件渲染:

在框架中,我们用 wx:if=”“ 来判断是否需要渲染该代码块:

1
<view wx:if="{{condition}}"> True </view>

也可以用 wx:elif 和 wx:else 来添加一个 else 块:

1
2
3
<view wx:if="{{length > 5}}"> 1 </view>
<view wx:elif="{{length > 2}}"> 2 </view>
<view wx:else> 3 </view>
Read more »

rails csv导出

Posted on 2017-07-03 17:54

1.在helper中定义一个导出方法 不能定义在model中 send_data方法不可以在model中用

Read more »

在vue 中 放大缩小图片

Posted on 2017-06-28 19:20

Vue-preview
1.在package.json dependencies里面加上
“vue-preview”: “^1.0.5”,
2.在main.js里面引用:
import VuePreview from ‘vue-preview’
Vue.use(VuePreview)
3.html:
<img class=”preview-img” v-for=”(item, index) in list” :src=”item.src” height=”100” @click=”$preview.open(index, list)”>

注意 : 图片形式必须为

{
src: ‘https://placekitten.com/600/400',
w: 600,
h: 400
}

搭建环境 --mysql安装的坑

Posted on 2017-06-24 11:19

代码拉下来以后,bundle install 的时候 mysql2死活安装不上
要先
$ brew install mysql
之后才能安装上gemfile中的mysql

rspec---单元测试

Posted on 2017-06-20 19:08

配置环境

  1. add to Gemfile:
    1
    2
    3
    4
    5
    6
    7
    8
    # Gemfile: 
    gem 'rspec-rails', '~> 3.5.2'
    然后运行:
    $ bundle exec rails generate rspec:install
    记得要把生成的.rspec 文件做个修改,删掉
    # .rspec file:
    --color
    # NO --warning, --require spec_helper
Read more »

程序中的等于判断

Posted on 2017-06-12 13:57

1.sql语句中: =
2.ES6的js: ===
3.大部分的脚本语言中: ==

js--根据选择不同 页面局部刷新

Posted on 2017-06-08 11:24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div class="detail-tr form-action">
<%= f.select(:good_id, Good.where(:goods_first_category => '1').map{|g| [g.name, g.id]}, {:include_blank=>"请选择菜品用料"}, :style => 'width: 200px;') %>
<%= f.text_field :amount, placeholder: '请输入菜品用量' %><p style="display:inline-block" id="material_unit"></p>
<%= link_to_remove_association('删除', f,
{ wrapper_class: 'detail-tr' })%>
<%= f.hidden_field :id %>
</div>

<script>
$('#dish_materials_attributes_0_good_id(select的id)').change(function(){
id = $(this).val()
$.get('/interface/goods/' + id, function(data){
$('#material_unit').text(data.unit)
})
})
</script>
1…212223…28

Lydia

This is lydia's blog

277 posts
1 categories
46 tags
© 2020 Lydia
Powered by Hexo
|
Theme — NexT.Muse v5.1.4