<template> <div id="myChartDemo" :style="{ height: '600px', width: '600px' }"></div> </template> <script setup lang="ts"> import { onMounted, ref, reactive } from 'vue' import * as echarts from 'echarts' import { lendlistApi, userinfoApi } from '@/api/index' import { da } from 'element-plus/es/locale'; onMounted(() => { callLendListChart() }) let lendListDB = ref([]) const callLendListChart = () => { lendlistApi.selectChart.call().then((res: any) => { initChartDemo(res) }) }const initChartDemo = (data: any) => { let dataList = JSON.parse(JSON.stringify(data).replace(/type/g, "name").replace(/count/g, "value")) let myChart = echarts.init(document.getElementById('myChartDemo')); let option = { tooltip: { trigger: 'item' }, legend: { top: '5%', left: 'center' }, series: [ { name: 'Access From', type: 'pie', radius: ['40%', '70%'], avoidLabelOverlap: false, itemStyle: { borderRadius: 10, borderColor: '#fff', borderWidth: 2 }, label: { show: false, position: 'center' }, emphasis: { label: { show: true, fontSize: 40, fontWeight: 'bold' } }, labelLine: { show: false }, data: dataList } ] };
时间: 2023-06-18 10:02:35 浏览: 44
这是一个使用 Vue 和 echarts 库来实现一个饼图的代码示例。其中,通过调用 lendlistApi.selectChart 接口获取数据并进行处理,最终渲染出一个带有样式的饼图。具体实现思路如下:
1. 在 template 中定义一个 div 容器,用于渲染 echarts 图表。
2. 在 script setup 中导入 echarts 库和 api 接口。使用 onMounted 钩子函数,在组件挂载后调用 callLendListChart 函数。
3. callLendListChart 函数是获取数据的函数,通过 lendlistApi.selectChart 接口来获取数据,并将数据传递给 initChartDemo 函数进行处理。
4. initChartDemo 函数是处理数据并渲染 echarts 图表的函数。首先将数据进行处理,将其转换成 echarts 需要的格式。然后使用 echarts.init 方法初始化图表,并将图表渲染到之前定义的 div 容器中。
5. 最后,定义 echarts 的配置项 option,其中包含了图表的样式、数据等信息。将 option 作为参数传递给 echarts.setOption 方法即可呈现出一个带有样式的饼图。
相关问题
<template> <div class="myInfo"> <div class="show" id="me"> <img src="../assets/timg.jpg" alt="" width="150px"><br> <span>张志伟</span> <p> 这里是用户:张志伟的个人中心 </p> <p> 用户已发表:0篇帖子 </p> <p> 用户已收藏:0篇帖子 </p> <p> 用户已打赏:0篇帖子 </p> <p> 用户已评论:0篇帖子 </p> </div> <div class="show" id="texts"> <p> 本项目为张志伟同学个人编写的vue期末考试作业 </p> </div> </div> </template> <script> export default { name: 'about', } </script> <style scoped> .myInfo{ color: black; width: 1000px; height: 600px; margin: 30px auto; background: white; box-shadow: 1px 1px 1px #ccc; } .show{ float: left; height: 100%; text-align: center; } #me{ width: 300px; border-right: 2px solid #ccc; } #me p{ color: #ccc; text-indent: 2em } #me img{ margin: 100px 0 20px 0; } #me span{ color: black; font-weight: bold; } #texts{ width:500px; text-align: center } #texts p{ margin: 200px 100px; width: 500px; text-indent: 2em; text-align: left } </style> 将p标签里的内容更改成可以点击并实行跳转的按钮
您可以使用`<router-link>`来创建一个可点击并实现跳转的按钮。您可以将`<p>`标签替换为以下代码:
```html
<router-link to="/your-route">
<button>
点击跳转
</button>
</router-link>
```
替换后的代码如下:
```html
<template>
<div class="myInfo">
<div class="show" id="me">
<img src="../assets/timg.jpg" alt="" width="150px"><br>
<span>张志伟</span>
<p>
<router-link to="/your-route">
<button>
点击跳转
</button>
</router-link>
</p>
<p>
用户已发表:0篇帖子
</p>
<p>
用户已收藏:0篇帖子
</p>
<p>
用户已打赏:0篇帖子
</p>
<p>
用户已评论:0篇帖子
</p>
</div>
<div class="show" id="texts">
<p>
本项目为张志伟同学个人编写的vue期末考试作业
</p>
</div>
</div>
</template>
<script>
export default {
name: 'about',
}
</script>
<style scoped>
.myInfo{
color: black;
width: 1000px;
height: 600px;
margin: 30px auto;
background: white;
box-shadow: 1px 1px 1px #ccc;
}
.show{
float: left;
height: 100%;
text-align: center;
}
#me{
width: 300px;
border-right: 2px solid #ccc;
}
#me p{
color: #ccc;
text-indent: 2em
}
#me img{
margin: 100px 0 20px 0;
}
#me span{
color: black;
font-weight: bold;
}
#texts{
width:500px;
text-align: center
}
#texts p{
margin: 200px 100px;
width: 500px;
text-indent: 2em;
text-align: left
}
</style>
```
请注意,您需要将`/your-route`替换为您要跳转的实际路由路径。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>页面布局</title> <style> /* 使用grid布局 */ .container { display: grid; grid-template-columns: 200px 1fr; /* 左侧宽度为200px,右侧占满剩余空间 */ grid-template-rows: 100vh; /* 总高度与视窗高度相同 */ } /* 左侧侧边栏样式 */ .sidebar { background-color: #f0f0f0; } /* 右侧盒子的容器样式 */ .boxes { display: flex; flex-direction: column; justify-content: space-between; height: 100%; } /* 右侧5个盒子样式 */ .box { flex-grow: 1; /* 平分宽度 */ background-color: #ccc; margin-bottom: 10px; } /* 第3,4,5个盒子样式 */ .box:nth-child(n+3) { border-radius: 10px; margin-top: 10px; } </style> </head> <body> <div class="container"> <div class="sidebar"> <!-- 左侧侧边栏内容 --> </div> <div class="boxes"> <div class="box"></div> <div class="box"></div> <div class="box"></div> <div class="box"></div> <div class="box"></div> </div> </div> </body> </html>将右侧第三个盒子分割为三个,由左到右的大小为:最大,最小,中间
可以通过在第三个盒子内部再创建三个子盒子,并设置它们的宽度来实现分割效果。具体代码如下:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>页面布局</title>
<style>
/* 使用grid布局 */
.container {
display: grid;
grid-template-columns: 200px 1fr; /* 左侧宽度为200px,右侧占满剩余空间 */
grid-template-rows: 100vh; /* 总高度与视窗高度相同 */
}
/* 左侧侧边栏样式 */
.sidebar {
background-color: #f0f0f0;
}
/* 右侧盒子的容器样式 */
.boxes {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
}
/* 右侧5个盒子样式 */
.box {
flex-grow: 1; /* 平分宽度 */
background-color: #ccc;
margin-bottom: 10px;
}
/* 第3,4,5个盒子样式 */
.box:nth-child(n+3) {
border-radius: 10px;
margin-top: 10px;
}
/* 第三个盒子内部的三个子盒子样式 */
.box:nth-child(3) > div {
height: 100%;
}
.box:nth-child(3) > div:first-child {
background-color: red;
width: 70%;
}
.box:nth-child(3) > div:nth-child(2) {
background-color: blue;
width: 10%;
}
.box:nth-child(3) > div:last-child {
background-color: green;
width: 20%;
}
</style>
</head>
<body>
<div class="container">
<div class="sidebar">
<!-- 左侧侧边栏内容 -->
</div>
<div class="boxes">
<div class="box"></div>
<div class="box"></div>
<div class="box">
<div></div>
<div></div>
<div></div>
</div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
</body>
</html>
```
在第三个盒子内部创建了三个子盒子,分别设置为红色、蓝色、绿色,并设置宽度为70%、10%、20%。其中,红色盒子宽度最大,绿色盒子宽度最小,蓝色盒子在中间。通过这样的设置,就可以实现分割效果了。
相关推荐
<%-- Created by IntelliJ IDEA. User: syp Date: 2023/5/22 Time: 13:59 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Denglu</title> </head> <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"> <fieldset style="width: auto; margin: 0px auto"> <legend> 欢迎使用常州工业职业技术学院人员管理系统 </legend>
<form action="loginSuccess.action"> 用户:<input type="text" name="username"/>
密码:<input type="password" name="password"/>
<input type="submit" value="登录"/> 注册 </form> </fieldset> </body> </html>
<form action="loginSuccess.action"> 用户:<input type="text" name="username"/>
密码:<input type="password" name="password"/>
<input type="submit" value="登录"/> 注册 </form> </fieldset>