zoukankan      html  css  js  c++  java
  • 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语法中专门用来输出字符串的

  • 相关阅读:
    续上-选课系统
    第一个java web的课堂练习-开始
    子类与父类方法间的关系
    课后作业-3
    小结
    Java中子类与基类变量间的赋值
    今日总结
    今日总结
    今日总结
    今日总结
  • 原文地址:https://www.cnblogs.com/sjqq/p/9031530.html
Copyright © 2011-2022 走看看