统计页面图形数据结构
let $dashChartBarsData = {
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
datasets: [
{
label: '当前近七天收入',
borderWidth: 1,
borderColor: 'rgba(0,0,0,0)',
backgroundColor: 'rgba(255,0,0,0.7)',
hoverBackgroundColor: "rgba(255,0,0,1)",
hoverBorderColor: "rgba(0,0,0,0)",
data: weekData['thisWeek']
},
{
label: '同期近七天收入',
borderWidth: 1,
borderColor: 'rgba(0,0,0,0)',
backgroundColor: 'rgba(44,62,80,0.7)',
hoverBackgroundColor: "rgba(44,62,80,1)",
hoverBorderColor: "rgba(0,0,0,0)",
data: weekData['lastWeek']
}
]
};
其中labels,和data需要获取数组变量,然后直接数组会报错问题描述: htmlentities() expects parameter 1 to be string, array given,只允许字符串;因此可以先json_encod(),赋值到模版;在js中 let weekData = JSON.parse('{$weekData|raw}'); // 转化为数组即可
thinkphp 中js获取php变量报错 htmlentities() expects parameter 1 to be string, array given
最新推荐文章于 2023-11-30 16:52:45 发布