提交 d586d3ad 编写于 作者: Q qq_63480508

Mon Mar 24 11:24:00 CST 2025 inscode

上级 aa50c4cb
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
"preview": "vite preview --port 4173" "preview": "vite preview --port 4173"
}, },
"dependencies": { "dependencies": {
"chart.js": "^4.4.8",
"guess": "^1.0.2", "guess": "^1.0.2",
"vue": "^3.2.37" "vue": "^3.2.37",
"vue-chartjs": "^5.3.2"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^3.0.1", "@vitejs/plugin-vue": "^3.0.1",
......
<script setup> <script setup>
import HelloWorld from './components/HelloWorld.vue' import HelloWorld from './components/HelloWorld.vue'
import TheWelcome from './components/TheWelcome.vue' // import TheWelcome from './components/TheWelcome.vue'
</script> </script>
<template> <template>
<header> <header>
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
<div class="wrapper"> <div class="wrapper">
<HelloWorld msg="You did it!" /> <HelloWorld msg="You did it!" />
......
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<template> <template>
<div class="greetings"> <div>
<h1 class="green">{{ msg }}</h1> <h2>饼状图示例</h2>
<h3> <PieChart :chartData="chartData" />
You’ve successfully created a project with
<a target="_blank" href="https://vitejs.dev/">Vite</a> +
<a target="_blank" href="https://vuejs.org/">Vue 3</a>.
</h3>
</div> </div>
</template> </template>
<style scoped> <script>
h1 { import { defineComponent, ref } from 'vue';
font-weight: 500; import { Pie } from 'vue-chartjs';
font-size: 2.6rem; import {
top: -10px; Chart as ChartJS,
} Title,
Tooltip,
Legend,
ArcElement,
} from 'chart.js';
h3 {
font-size: 1.2rem;
}
.greetings h1, ChartJS.register(Title, Tooltip, Legend, ArcElement);
.greetings h3 {
text-align: center; export default defineComponent({
} components: {
PieChart: Pie,
},
setup() {
const chartData = ref({
labels: ['红色', '蓝色', '黄色', '绿色', '紫色', '橙色'],
datasets: [
{
label: '我的饼状图',
backgroundColor: [
'#FF6384',
'#36A2EB',
'#FFCE56',
'#4BC0C0',
'#9966FF',
'#FF9F40',
],
data: [12, 19, 3, 5, 2, 3],
},
],
});
return {
chartData,
};
},
});
</script>
@media (min-width: 1024px) { <style scoped>
.greetings h1, h2 {
.greetings h3 { text-align: center;
text-align: left;
}
} }
</style> </style>
<script setup>
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template> <template>
<WelcomeItem> <div>
<template #icon> <v-for >
<DocumentationIcon /> </div>
</template> </template>
<template #heading>Documentation</template>
Vue’s
<a target="_blank" href="https://vuejs.org/">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite</a>. The recommended IDE
setup is <a href="https://code.visualstudio.com/" target="_blank">VSCode</a> +
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>. If you need to test
your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank">Cypress</a> and
<a href="https://on.cypress.io/component" target="_blank"
>Cypress Component Testing</a
>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a target="_blank" href="https://pinia.vuejs.org/">Pinia</a>,
<a target="_blank" href="https://router.vuejs.org/">Vue Router</a>,
<a target="_blank" href="https://test-utils.vuejs.org/">Vue Test Utils</a>, and
<a target="_blank" href="https://github.com/vuejs/devtools">Vue Dev Tools</a>. If you need more
resources, we suggest paying
<a target="_blank" href="https://github.com/vuejs/awesome-vue">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a target="_blank" href="https://chat.vuejs.org">Vue Land</a>, our official Discord server, or
<a target="_blank" href="https://stackoverflow.com/questions/tagged/vue.js">StackOverflow</a>.
You should also subscribe to
<a target="_blank" href="https://news.vuejs.org">our mailing list</a> and follow the official
<a target="_blank" href="https://twitter.com/vuejs">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem> <script>
<template #icon> export default({
<SupportIcon /> data(){
</template> return{
<template #heading>Support Vue</template>
}
}
})
</script>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a target="_blank" href="https://vuejs.org/sponsor/">becoming a sponsor</a>.
</WelcomeItem>
</template>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册