• MVC Razor与javascript混编(js中嵌入razor)


    其中的关键是输出js上的纯文本内容,让浏览器解析为其中的js代码

    <script>
        BUI.use('common/main',function(){
            var config = [
            {
                id: '1',
                menu:
                [
             @{ 
                 int ruiyalel = (int)Session["ruiyaLev"];
                 int happyfamilylel = (int)Session["happyfamilyLev"];


                 if (ruiyalel > 0) {
                  <text>
                  {
                      text: '瑞亚官网', items: [{ id: '3', text: '瑞亚新闻', href: 'DBSystem/ruiya/News' }, ]
                  },
                  </text>
                 }
                 if (happyfamilylel > 0){
                  <text>
                  {
                      text: '全家乐', items: [{ id: '4', text: '新闻管理', href: 'DBSystem/happyfamily/News' },
                                             { id: '5', text: '活动管理', href: 'DBSystem/happyfamily/Activity' },
                                             { id: '6', text: '综合管理', href: 'DBSystem/happyfamily/GeneralMes' }, ]
                  },
                  </text>
                 }


             }            
                ]


            }];


            new PageUtil.MainPage({
                modulesConfig : config
            });


        });
        </script>

    @:表示后面直接输出字符串

              <text></text>表示里面输出的是字符串

              两种方式可以任选一种,注意<text>不是html标签,他是razor语法中专门用来输出字符串的

  • 相关阅读:
    转 TClientDataSet的地位
    让Delphi的DataSnap发挥最大效率
    Delphi2010强化的反射
    Delphi的内存管理及内存泄露问题
    DataSnap 传输过滤器
    delphi dataset not in edit or insert mode
    CSS中Zoom属性的一些介绍
    Linux进程分析
    MIPS处理器介绍
    Linux内存管理
  • 原文地址:https://www.cnblogs.com/sjqq/p/9031530.html
Copyright © 2020-2023  润新知