格式化是通过格式操作使任意类型的数据转换成一个字符串。例如下面这样
代码如下:
<script>
console.log(chopper.format('{0} - {1} - {2}', 12, 24, 25)); // outputs "12 - 24 - 25"
</script>
下面是一个完整的代码,可以复制到自己的项目中。
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
(function() {
var chopper = window.chopper = window.chopper || { cultures: {} },
math = Math,
formatRegExp = //{(/d+)(:[^/}]+)?/}/g,
FUNCTION = "function",
STRING = "string",
NUMBER = "number",
OBJECT = "object",
NULL = "null",
BOOLEAN = "boolean",
UNDEFINED = "undefined",
slice = [].slice,
globalize = window.Globalize,
standardFormatRegExp = /^(n|c|p|e)(/d*)$/i,
literalRegExp = /(//.)|(['][^']*[']?)|(["][^"]*["]?)/g,
commaRegExp = //,/g,
EMPTY = "",
POINT = ".",
新闻热点
疑难解答
图片精选