我想將值從 php 傳遞到 js 文件,像這樣的代碼但不工作有什么問題嗎?謝謝php 文件$var = 10;<script>var phpVar = "<?php echo json_encode($var) ?>;";</script><script type="text/javascript" src='vendor/circliful/circliful.custom.js'></script>js 文件$("#overallProgress").circliful({ animationStep: 5, foregroundBorderWidth: 12, backgroundBorderWidth: 6, percent: 'alert(phpVar);', **<-- place value from php** fontColor: '#000000', foregroundColor: '#1a8e5f', backgroundColor: 'rgba(0, 0, 0, 0.1)',// icon: '\eab4', iconColor: '#1a8e5f', iconPosition: 'middle',// text: 'Statistik', textBelow: true, animation: 1, animationStep: 1, start: 2, showPercent: 1, });抱歉,我在 php 中有錯誤代碼,這是正確的代碼<?php$var = 67;?><script>var phpVar = <?php echo json_encode($var) ?>;</script><script type="text/javascript" src='vendor/circliful/circliful.custom.js'></script>
- 1 回答
- 0 關注
- 107 瀏覽
添加回答
舉報
0/150
提交
取消