fdsczk 2016-07-24 13:12 采纳率: 0%
浏览 3034

js使用i18n获取的资源无法显示

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>个人测试</title>

</head>

<body onload="load()">
<div id="content" > 
     <div> 
         <label id="label_username"></label> 
         <input type="text" id="button-login"></input> 
     </div> 
     <div> 
         <label id="label_password"></label> 
         <input type="password" id="label-username"></input> 
     </div> 
     <input type="button" id="label-password"/> 
 </div>

</body>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.i18n.properties-min-1.0.9.js"></script>
<script type="text/javascript">
  function load(){  $(function(){
        jQuery.i18n.properties({
            name : 'strings', //资源文件名称

            path : '/i18n/', //资源文件路径

            mode : 'map', //用Map的方式使用资源文件中的值

            language:'en',

            callback : function() {//加载成功后设置显示内容

            alert($.i18n.prop('like'));

                $('#button-login').value=$.i18n.prop('home');

                $('#label-username').html($.i18n.prop('like'));

            }
        });
    });}
</script>
</html>

代码是网上找的,但是无法显示资源文件里的键值。alert一下,显示[like],文件里的是Like。那位大神解答一下。还有获取中文的时候乱码。

  • 写回答

2条回答

  • qq_34285369 2016-07-24 13:28
    关注

    我们在工作中一般把编码设置为UTF-8,关于数据获取不到,你可以看看路径有没有问题

    评论

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器