创建自己的模板之----自定义js代码块

前言:整理的常用快捷显示代码块方式

snippet "return true;" do |s|
  s.trigger = "rtrue"
  s.expansion = "return true;"
  end
  
  snippet "return false;" do |s|
  s.trigger = "rfalse"
  s.expansion = "return false;"
  end
  
  snippet "function funnname(){}" do |s|      #=========function
  s.trigger = "ff"
  s.expansion = "function funname() {
    $1                    
}"
  end
  
  snippet "console.log()" do |s|                #=========console.log
  s.trigger = "cc"
  s.expansion = "console.log($1);"
  end
  
  
  
  snippet "_a" do |s|                           #==============模块内对a绑定
  s.trigger = "ja"
  s.expansion = "\\$(\".main\").on(\"click\",\"$1\",function(e){
  e.preventDefault(); 
  $0
})"
  end
  
  snippet "bar_li" do |s|                        #=============导航栏
  s.trigger = "jbar"
  s.expansion = "\\$(\".bar\").on(\"click\",\"li\",function(){
  \\$(this).addClass(\"act\").siblings().removeClass(\"act\");
})"
  end
  
  
  snippet "class_on_click" do |s|               #================on绑定方法
  s.trigger = "jon"
  s.expansion = "\\$(\"$1\").on(\"click\",\"$0\",function(){
  
})"
  end
  
  snippet "fori" do |s|                          #=============for循环方法
  s.trigger = "jfori"
  s.expansion = "for(var i=0,len=$1;i<len;i++){
    $0
}"
  end
  
  snippet "ajax" do |s|                           #==============ajax
  s.trigger = "ajax"
  s.expansion = "\\$.ajax({
    type: \"post\",
    url: url + \"\",
    contentType: \"application/json\",
    async: true,
    dataType:\"json\",
    data: JSON.stringify({}}),
    success: function(data) {
        console.log(data);
        if(data.code==0){
        }
    }
});"
  end
  
  snippet "Request_name" do |s|                    #==============git参数
  s.trigger = "jrequest"
  s.expansion = "Request.id"
  end
  
  snippet "page_showpage" do |s|                    #==============分页
  s.trigger = "jpage_showpage"
  s.expansion = "ajaxTest(1);
function ajaxTest(num) {
    GAME.currentpage = num;
    var totalPage = 5;
    if (data.data.totalPage < 2) {
        \\$(\"#page\").hide();
    } else {
        \\$(\"#page\").show();
       \\$(\"#page\").paging({
            pageNo : num,
            totalPage : totalPage,
            callback : function(num) {
                var isget = SDHF.isgetpage(totalPage, num);
                if (isget) {
                    listserch.currentPage = num;
                    ajaxTest(num, listserch);
                }
            }
        })
    }
}"
  end
  
  snippet "code==0" do |s|                    #==============code==0
  s.trigger = "code"
  s.expansion = "if(data.code==0){
    $1
}"
  end
  
    snippet "code==-1" do |s|                    #==============code==-1
  s.trigger = "code"
  s.expansion = "if(data.code==-1){
    $1
}"
  end
  
  snippet "layer_alert_0感叹号" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:0,time:2000}); 
})"
  end
  
  snippet "layer_alert_1正确" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:1,time:2000}); 
})"
  end
  
  snippet "layer_alert_2错误" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:2,time:2000}); 
})"
  end
  
  snippet "layer_alert_3问好" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:3,time:2000}); 
})"
  end
  
  snippet "layer_alert_4锁住" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:4,time:2000}); 
})"
  end
  
  snippet "layer_alert_5哭脸" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:5,time:2000}); 
})"
  end
  
   snippet "layer_alert_6笑脸" do |s|                    #==============
  s.trigger = "jalert"
  s.expansion = "layui.use('layer', function() {
    layer.msg(\"Hello\",{icon:6,time:2000}); 
})"
  end

阅读更多
个人分类: 模板
上一篇创建自己的模板之----扩展自定义代码块感受
下一篇拖拽相关的一共有7个方法
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭