迅睿CMS框架是一款PHP8高性能·簡(jiǎn)單易用的CMS開源開發(fā)框架,基于MIT開源許可協(xié)議發(fā)布,免費(fèi)且不限制商業(yè)使用,是免費(fèi)開源的產(chǎn)品,以萬(wàn)端互聯(lián)為設(shè)計(jì)理念,支持的微信公眾號(hào)、小程序、APP客戶端、移動(dòng)端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
聯(lián)系官方銷售客服
1835022288
028-61286886
文章閱讀兩超過(guò)千和萬(wàn)后,怎么K+、W+顯示?在這里找到的代碼生成靜態(tài)后,不能動(dòng)態(tài)增加。有沒有生成靜態(tài)后也可以動(dòng)態(tài)增加的代碼?
回復(fù)@外聘專員-明礬軟件 百度AI用啥詞提問 ??
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Number Format Example</title>
<script>
function formatNumber(num) {
if (num >= 1000 && num < 10000) {
return (num / 1000) + "k";
} else if (num >= 10000) {
return (num / 10000) + "w";
}
return num;
</script>
</head>
<body>
<p id="numberDisplay"></p>
var number = 1500;
document.getElementById('numberDisplay').textContent = formatNumber(number);
</body>
</html>
百度AI生成的!
很簡(jiǎn)單也好用!
回復(fù)@王小五 用{intval($hits)} 統(tǒng)計(jì),不會(huì)動(dòng)態(tài)增加訪問數(shù)量啊
官方說(shuō)靜態(tài)是死頁(yè)面,動(dòng)態(tài)數(shù)據(jù)就用這個(gè)。
http://223987.com/doc/313.html
回復(fù)@王小五 文章已經(jīng)生產(chǎn)了靜態(tài)頁(yè)面,用{dr_show_hits($id)}正常可以動(dòng)態(tài)增加閱讀量,但是用了那個(gè)變W的js記調(diào)不出了
把{dr_show_hits($id)}刪掉
改為:
<span class="dr_show_hits_{$id}">0</span> <script type="text/javascript"> $.ajax({ type: "GET", url:"/index.php?s=api&c=module&siteid=1&app=news&m=hits&id={$id}", dataType: "jsonp", success: function(data){ if (data.code) { $(".dr_show_hits_{$id}").html( formatNumber(data.msg) ); } else { dr_tips(0, data.msg); } } }); function formatNumber(num) { if (num >= 1000 && num < 10000) { return (num / 1000).toFixed(2) + "k"; } else if (num >= 10000) { return (num / 10000).toFixed(2) + "w"; } return num.toFixed(2); } </script>
回復(fù)@小黃人 18html 這是需要用http://223987.com/doc/313.html這個(gè)里面的方法調(diào)用嗎?可以直接加在文章模板嗎
回復(fù)@句覓 我沒說(shuō)就是不需要,直接按我描述的操作就可以了,該代碼是修改 show.html 的;
如果是列表什么的,建議使用函數(shù)
如果是列表,或者其他地方調(diào)用請(qǐng)使用
請(qǐng)把以下代碼放在 /config/custom.php,然后使用函數(shù)調(diào)用 {dr_formatNumber($t.hits)}
function dr_formatNumber($num) { if ($num >= 1000 && $num < 10000) { return number_format($num / 1000, 2) . "k"; } elseif ($num >= 10000) { return number_format($num / 10000, 2) . "w"; } return number_format($num, 2); }
回復(fù)@小黃人 18html
<div class="left-comment"><span class="dr_show_hits_9160">0</span>
<script type="text/javascript">
$.ajax({
type: "GET",
url:"/index.php?s=api&c=module&siteid=1&app=news&m=hits&id=9160",
dataType: "jsonp",
success: function(data){
if (data.code) {
$(".dr_show_hits_9160").html( formatNumber(data.msg) );
} else {
dr_tips(0, data.msg);
});
return (num / 1000).toFixed(2) + "k";
return (num / 10000).toFixed(2) + "w";
return num.toFixed(2);
</script></div>
閱讀量顯示為0 ??
回復(fù)@小黃人 18html 知道啥原因了
回復(fù)@小黃人 18html 刷新后,就又變成0了,啥情況
回復(fù)@小黃人 18html 大佬,點(diǎn)擊不到1千的怎么正常顯示
點(diǎn)擊不到1000就返回原值唄
<span class="dr_show_hits_{$id}">0</span> <script type="text/javascript"> $.ajax({ type: "GET", url:"/index.php?s=api&c=module&siteid=1&app={MOD_DIR}&m=hits&id={$id}", dataType: "jsonp", success: function(data){ if (data.code) { $(".dr_show_hits_{$id}").html( formatNumber(data.msg) ); } else { dr_tips(0, data.msg); } } }); function formatNumber(num) { if (num >= 1000 && num < 10000) { return (num / 1000).toFixed(2) + "k"; } else if (num >= 10000) { return (num / 10000).toFixed(2) + "w"; } return num; } </script>
回復(fù)@小黃人 18html 大佬,放到首頁(yè)或者其他位置的時(shí)候,比如183個(gè)點(diǎn)擊,怎么不顯示小數(shù)點(diǎn)后兩位,而5120點(diǎn)擊的時(shí)候顯示5.12K呢
function dr_formatNumber($num) { if ($num >= 1000 && $num < 10000) { return number_format($num / 1000, 2) . "k"; } elseif ($num >= 10000) { return number_format($num / 10000, 2) . "w"; } return $num; }
回復(fù)@小黃人 18html 按照你給的代碼放了,就是百位的時(shí)候會(huì)顯示.00,百位的.00怎么去掉,而千位的時(shí)候正常顯示小數(shù)點(diǎn)后面的數(shù)字
回復(fù)@小黃人 18html 就是不到一千,就顯示原值
回復(fù)@外聘專員-明礬軟件 百度AI用啥詞提問 ??
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Number Format Example</title>
<script>
function formatNumber(num) {
if (num >= 1000 && num < 10000) {
return (num / 1000) + "k";
} else if (num >= 10000) {
return (num / 10000) + "w";
}
return num;
}
</script>
</head>
<body>
<p id="numberDisplay"></p>
<script>
var number = 1500;
document.getElementById('numberDisplay').textContent = formatNumber(number);
</script>
</body>
</html>
百度AI生成的!
很簡(jiǎn)單也好用!
回復(fù)@王小五 用{intval($hits)} 統(tǒng)計(jì),不會(huì)動(dòng)態(tài)增加訪問數(shù)量啊
官方說(shuō)靜態(tài)是死頁(yè)面,動(dòng)態(tài)數(shù)據(jù)就用這個(gè)。
http://223987.com/doc/313.html
回復(fù)@王小五 文章已經(jīng)生產(chǎn)了靜態(tài)頁(yè)面,用{dr_show_hits($id)}正常可以動(dòng)態(tài)增加閱讀量,但是用了那個(gè)變W的js記調(diào)不出了
把{dr_show_hits($id)}刪掉
改為:
回復(fù)@小黃人 18html 這是需要用http://223987.com/doc/313.html這個(gè)里面的方法調(diào)用嗎?可以直接加在文章模板嗎
回復(fù)@句覓 我沒說(shuō)就是不需要,直接按我描述的操作就可以了,該代碼是修改 show.html 的;
如果是列表什么的,建議使用函數(shù)
如果是列表,或者其他地方調(diào)用請(qǐng)使用
請(qǐng)把以下代碼放在 /config/custom.php,然后使用函數(shù)調(diào)用 {dr_formatNumber($t.hits)}
回復(fù)@小黃人 18html
<div class="left-comment"><span class="dr_show_hits_9160">0</span>
<script type="text/javascript">
$.ajax({
type: "GET",
url:"/index.php?s=api&c=module&siteid=1&app=news&m=hits&id=9160",
dataType: "jsonp",
success: function(data){
if (data.code) {
$(".dr_show_hits_9160").html( formatNumber(data.msg) );
} else {
dr_tips(0, data.msg);
}
}
});
function formatNumber(num) {
if (num >= 1000 && num < 10000) {
return (num / 1000).toFixed(2) + "k";
} else if (num >= 10000) {
return (num / 10000).toFixed(2) + "w";
}
return num.toFixed(2);
}
</script></div>
閱讀量顯示為0 ??
回復(fù)@小黃人 18html 知道啥原因了
回復(fù)@小黃人 18html 刷新后,就又變成0了,啥情況
回復(fù)@小黃人 18html 大佬,點(diǎn)擊不到1千的怎么正常顯示
點(diǎn)擊不到1000就返回原值唄
回復(fù)@小黃人 18html 大佬,放到首頁(yè)或者其他位置的時(shí)候,比如183個(gè)點(diǎn)擊,怎么不顯示小數(shù)點(diǎn)后兩位,而5120點(diǎn)擊的時(shí)候顯示5.12K呢
如果是列表,或者其他地方調(diào)用請(qǐng)使用
請(qǐng)把以下代碼放在 /config/custom.php,然后使用函數(shù)調(diào)用 {dr_formatNumber($t.hits)}
回復(fù)@小黃人 18html 按照你給的代碼放了,就是百位的時(shí)候會(huì)顯示.00,百位的.00怎么去掉,而千位的時(shí)候正常顯示小數(shù)點(diǎn)后面的數(shù)字
回復(fù)@小黃人 18html 就是不到一千,就顯示原值