教你使用Vue实战笔记本案例(效果图+贡献所有代码)

学习Vue,从做实战开始,没有华丽的css装饰和复杂的html界面,只关注学习Vue本身。

功能很简单,可以直接看图即可,代码放在下面,看前记得点个赞,养成好习惯哦,关注我也可以的哦,因为我时常会出很多Vue小项目哦,当然有问题你在底下评论说话呀

Vue实战系列

教你使用Vue实战轮播图案例(效果图+贡献所有代码)

先上效果图
在这里插入图片描述
操作一波笔记本
在这里插入图片描述
在这里插入图片描述

笔记本小项目代码

(特别提醒:导入的外链式Vue.js记得换成自己的路径)
@粗心的小伙伴

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>一颗剽悍的种子</title>
		<style>
			header,article,footer{
				width: 500px;
				margin: auto;
				border: 1px solid #000;
			}
			header{
				height: 50px;
			}
			header input:first-child{
				width: 370px;
				border-radius: 0.5em;
				margin-top: 6px;
				margin-left: 30px;
				margin-right: 30px;
				height:30px;
				float: left;
			}
			input:nth-child(2){
				margin-top: 5px;
				height:36px;
				border-radius: 0.5em;
				cursor: pointer;
			}
			
			article{
				position: relative;
				min-height: 200px;
			}
			article li span{
				cursor:pointer;
			}
			article div:first-child{
				width: 100%;
				height: 30px;
				position: absolute;
				border: 1px solid #000;
			}
			footer{
				height: 30px;
			}
			footer div{
				text-align: center;
				line-height: 33px;
				float: left;
				width: 160px;
			}
			footer div:last-child span{
				padding: 3px;
				border: 1px solid #000000;
				cursor: pointer;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<center><h1>一颗剽悍的种子</h1></center>
			<!-- 头部输入笔记 -->
			<header>
				<input v-model="content" type="text"/>
				<input type="button" v-on:click="add()"  value="写下" />
			</header>
			<!-- 文章内容 -->
			<article>
				<ol>
					<li v-for="(item,index) in lists">
						<span v-on:click="remove(index)">{{item}}</span>
					</li>
				</ol>
			</article>
			<!-- 底部操作笔记 -->
			<footer>
				<div>{{lists.length}} 条笔记</div>
				<div>{{this.lists.toString().replace(/,/g,"").length}} 个字</div>
				<div><span v-on:click="clear()">清空所有笔记</span></div>
			</footer>
		</div>
		<!-- vue.js要换成自己的路径 -->
		<script src="js/vue.js"></script>
		<script>
			var app = new Vue({
				el:"#app",
				data:{
					lists:["关注","点赞","评论","一颗剽悍的种子"],
					content:""
				},
				methods:{
					//添加笔记
					add:function(){
						this.lists.push(this.content);
					},
					//删除对应的第几条笔记
					remove:function(index){
						var r = confirm("确认要删除第"+(index+1)+"条笔记吗?");
						if(r){
							this.lists.splice(index,1);
						}
					},
					//清除所有笔记
					clear:function(){
						this.lists = [];
					}
				}
			})
		</script>
	</body>
</html>

最后:

为了更好的阅读体验,我把想说的话都放在了下面,嘿嘿。

我是一颗剽悍的种子 把我会的,认真的分享 是我写博客一直不变的信条。
如果你能看到这篇博文,说明咱们还是很有缘的;希望能带给你一些许帮助,创作的不易,
把我文章的知识带走,你的三连留下,点赞,评论,关注,是我最大的动力。

  • 14
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Vue 3是Vue.js的最新版本,它具有更好的性能、更好的TypeScript支持、更好的开发者体验等特点。Vite是一个轻量级的Web应用程序构建工具,它可以快速地构建Vue项目,同时支持TypeScript。AntV X6是一个强大的图形可视化库,它可以帮助开发人员快速地创建各种类型的图表和流程图。 下面是一个使用Vue 3、Vite、TypeScript和AntV X6的自定义节点元素案例代码: ``` <template> <div class="app"> <x6-graph :graph="graph" :width="800" :height="600"> <template #default="{ node }"> <x6-rect v-if="node.data.type === 'rect'" :node="node" :width="node.getSize().width" :height="node.getSize().height" :fill="node.getStyle().fillColor" :stroke="node.getStyle().strokeColor" /> <x6-circle v-else-if="node.data.type === 'circle'" :node="node" :r="node.getSize().width / 2" :fill="node.getStyle().fillColor" :stroke="node.getStyle().strokeColor" /> </template> </x6-graph> </div> </template> <script lang="ts"> import { defineComponent, ref } from 'vue' import { Graph, Node, Rect, Circle } from '@antv/x6' import { useUndoRedo } from '@antv/x6-vue' export default defineComponent({ setup() { const graph = ref<Graph>() useUndoRedo({ graph }) const nodes = [ { type: 'rect', x: 100, y: 100, width: 100, height: 50, style: { fillColor: '#ffffff', strokeColor: '#000000', }, }, { type: 'circle', x: 300, y: 100, width: 100, height: 100, style: { fillColor: '#ffffff', strokeColor: '#000000', }, }, ] graph.value = new Graph({ container: document.querySelector('.app')!, }) nodes.forEach((node) => { const shape = node.type === 'rect' ? Rect : Circle const newNode = new Node({ x: node.x, y: node.y, width: node.width, height: node.height, shape, data: node, }) newNode.setStyle(node.style) graph.value.addNode(newNode) }) return { graph } }, }) </script> ``` 此代码演示了如何在Vue 3项目使用AntV X6创建自定义节点元素。在这个示例中,我们创建了两个不同类型的节点:一个矩形和一个圆形。我们通过给每个节点添加一个"type"属性来区分它们的类型。然后,我们在Vue模板中使用了`x6-rect`和`x6-circle`组件来渲染节点元素,这些组件分别对应于`Rect`和`Circle`节点形状。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值