opal对layer弹层的简单封装

作者在 2022-10-22 22:55:40 发布以下内容
def layer_open(h)
  type = h[:type] || 1
  title = h[:title]
  skin = h[:skin] || 'layui-layer-rim'
  area = h[:are] || ['420px', '240px']
  content = h[:content]
  success = h[:success] || proc {}

  layer_index = `
    layer.open({
      type: #{type},
      title: #{title},
      skin: #{skin},
      area: #{area},
      content: #{content},
      success: #{success},
    })
  `

  return layer_index
end

def layer_close(index)
  `layer.close(#{index})`
end

作者在 2022-10-22 22:59:05 补充以下内容

应用示例

创建弹层:
layer_index = layer_open({
  title: '弹层标题',
  content: '弹层内容',
  success: proc do
    alert '触发回调函数'
  end
})
关闭弹层:
layer_close(layer_index)

Ruby | 阅读 298 次
文章评论,共0条
游客请输入验证码
浏览2559693次
文章归档