V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
leeyuzhe
V2EX  ›  前端开发

Materialize 框架里有个 form 按钮 Date Picker 工作不正常

  •  
  •   leeyuzhe · 2015-06-24 14:58:00 +08:00 · 3716 次点击
    这是一个创建于 3201 天前的主题,其中的信息可能已经有所发展或是发生改变。
    按他描述只需添加一个类datepicker即可
    <input type="date" class="datepicker">
    然而我这边根本没有效果,是不是有什么js没引入呀,小弟做后端的对前端了解不深,请指点
    附我的代码:
    <!DOCTYPE html>
    <html>
    <head>
    <!--Import materialize.css-->
    <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>

    <!--Let browser know website is optimized for mobile-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">-->
    </head>

    <body>
    <!--Import jQuery before materialize.js-->
    <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="js/materialize.min.js"></script>
    <input type="date" class="datepicker">
    </body>
    </html>
    4 条回复    2015-06-24 19:28:36 +08:00
    leeyuzhe
        1
    leeyuzhe  
    OP
       2015-06-24 15:09:28 +08:00
    我的(根本没有js加载上)
    他的
    guchengf
        2
    guchengf  
       2015-06-24 17:16:42 +08:00
    class 是用来判断对象的,需要 js 进行初始化
    $('.datepicker').pickadate({
    selectMonths: true, // Creates a dropdown to control month
    selectYears: 15 // Creates a dropdown of 15 years to control year
    });
    leeyuzhe
        3
    leeyuzhe  
    OP
       2015-06-24 19:08:48 +08:00
    @guchengf 把这两句jq加到前面去了,然并卵呀
    leeyuzhe
        4
    leeyuzhe  
    OP
       2015-06-24 19:28:36 +08:00
    @guchengf 谢谢你可以了,在页面加载后执行这段js初始化就可以了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5427 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 08:51 · PVG 16:51 · LAX 01:51 · JFK 04:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.