当前位置: 首页 > news >正文

Web前端-Vue2+Vue3基础入门到实战项目-Day5(自定义指令, 插槽, 案例商品列表, 路由入门)

自定义指令

基本使用

  • 自定义指令: 自己定义的指令, 可以封装一些dom操作, 扩展额外功能
  • 全局注册
    // 1. 全局注册指令
    Vue.directive('focus', {// inserted 会在 指令所在的元素, 被插入到页面中时触发inserted (el) {// el 就是指令所绑定的元素// console.log(el)el.focus()}
    })
    
  • 局部注册
    <script>
    export default {
    // mounted(){
    //   this.$refs.inp.focus()
    // }// 2. 局部注册指令
    directives: {// 指令名: 指令的配置项focus: {inserted (el) {el.focus()}}
    }
    }
    </script>
    

指令的值

  • v-指令名=“指令值”, 通过等号可以绑定指令的值
  • 通过binding.value可以拿到指令的值
  • 通过update钩子, 可以监听指令值的变化, 进行dom更新操作
<template><div><h1 v-color="color1">指令的值1测试</h1><h1 v-color="color2">指令的值2测试</h1></div>
</template><script>
export default {data () {return {color1: 'red',color2: 'green'}},directives: {color: {// 1. inserted 提供的是元素被添加到页面中时的逻辑inserted (el, binding) {// binding.value 就是指令的值el.style.color = binding.value},// 2. update 指令的值修改的时候触发, 提供值变化后, dom更新的逻辑update(el, binding){// console.log(binding.value)el.style.color = binding.value}}}
}
</script><style></style>

封装v-loading指令

  • 核心思路
    1. 准备类名loading, 通过伪元素提供遮罩层
    2. 添加或移除类名, 实现loading蒙层的添加移除
    3. 利用指令语法, 封装v-loading通用指令
      inserted钩子中, binding.value判断指令的值, 设置默认状态
      update钩子中, binding.value判断指令的值, 更新类名状态
<template><div class="main"><div class="box" v-loading="isLoading"><ul><li v-for="item in list" :key="item.id" class="news"><div class="left"><div class="title">{{ item.title }}</div><div class="info"><span>{{ item.source }}</span><span>{{ item.time }}</span></div></div><div class="right"><img :src="item.img" alt=""></div></li></ul></div></div>
</template><script>
// 安装axios =>  yarn add axios
import axios from 'axios'// 接口地址:http://hmajax.itheima.net/api/news
// 请求方式:get
export default {data () {return {list: [],isLoading: true}},directives: {loading(el, binding){binding.value ? el.classList.add('loading') : el.classList.remove('loading')},update(el, binding){binding.value ? el.classList.add('loading') : el.classList.remove('loading')}},async created () {// 1. 发送请求获取数据const res = await axios.get('http://hmajax.itheima.net/api/news')setTimeout(() => {// 2. 更新到 list 中this.list = res.data.datathis.isLoading = false}, 2000)}
}
</script><style>
/* 伪类 - 蒙层效果 */
.loading:before {content: '';position: absolute;left: 0;top: 0;width: 100%;height: 100%;background: #fff url('./loading.gif') no-repeat center;
}/* .box2 {width: 400px;height: 400px;border: 2px solid #000;position: relative;
} */.box {width: 800px;min-height: 500px;border: 3px solid orange;border-radius: 5px;position: relative;
}
.news {display: flex;height: 120px;width: 600px;margin: 0 auto;padding: 20px 0;cursor: pointer;
}
.news .left {flex: 1;display: flex;flex-direction: column;justify-content: space-between;padding-right: 10px;
}
.news .left .title {font-size: 20px;
}
.news .left .info {color: #999999;
}
.news .left .info span {margin-right: 20px;
}
.news .right {width: 160px;height: 120px;
}
.news .right img {width: 100%;height: 100%;object-fit: cover;
}
</style>

插槽

默认插槽

  • 使用步骤
    1. 先在组件内用slot占位
    2. 使用组件时, 传入具体标签内容插入
  • 插槽中的内容会作为默认值
  • MyDialog.vue
    <template><div class="dialog"><div class="dialog-header"><h3>友情提示</h3><span class="close">✖️</span></div><div class="dialog-content"><!-- 1. 在需要定制的位置, 使用slot占位 --><slot></slot></div><div class="dialog-footer"><button>取消</button><button>确认</button></div></div>
    </template><script>
    export default {data () {return {}}
    }
    </script><style scoped>
    * {margin: 0;padding: 0;
    }
    .dialog {width: 470px;height: 230px;padding: 0 25px;background-color: #ffffff;margin: 40px auto;border-radius: 5px;
    }
    .dialog-header {height: 70px;line-height: 70px;font-size: 20px;border-bottom: 1px solid #ccc;position: relative;
    }
    .dialog-header .close {position: absolute;right: 0px;top: 0px;cursor: pointer;
    }
    .dialog-content {height: 80px;font-size: 18px;padding: 15px 0;
    }
    .dialog-footer {display: flex;justify-content: flex-end;
    }
    .dialog-footer button {width: 65px;height: 35px;background-color: #ffffff;border: 1px solid #e1e3e9;cursor: pointer;outline: none;margin-left: 10px;border-radius: 3px;
    }
    .dialog-footer button:last-child {background-color: #007acc;color: #fff;
    }
    </style>
    
  • App.vue
    <template><div><!-- 2. 在使用组件时, 组件标签填入内容 --><MyDialog>你确认要删除吗</MyDialog><MyDialog>你确认要退出吗</MyDialog></div>
    </template><script>
    import MyDialog from "./components/MyDialog.vue"
    export default {data() {return {}},components: {MyDialog,},
    }
    </script><style>
    body {background-color: #b3b3b3;
    }
    </style>
    

具名插槽

  • slot占位, 给name属性起名字来区分
  • template配合v-slot:插槽名分发内容
  • v-slot:插槽名 可以简化为 #插槽名

App.vue

<template><div><MyDialog><!-- 需要通过template标签包裹分发的结构 --><template v-slot:head><div>我是大标题</div></template><template v-slot:content><div>我是内容</div></template><template #footer><button>确认</button><button>取消</button></template></MyDialog></div>
</template><script>
import MyDialog from './components/MyDialog.vue'
export default {data () {return {}},components: {MyDialog}
}
</script><style>
body {background-color: #b3b3b3;
}
</style>

MyDialog.vue

<template><div class="dialog"><div class="dialog-header"><!-- 一旦插槽起了名字, 就是具名插槽, 就只支持定向分发 --><slot name="head"></slot></div><div class="dialog-content"><slot name="content"></slot></div><div class="dialog-footer"><slot name="footer"></slot></div></div>
</template><script>
export default {data() {return {}},
}
</script><style scoped>
* {margin: 0;padding: 0;
}
.dialog {width: 470px;height: 230px;padding: 0 25px;background-color: #ffffff;margin: 40px auto;border-radius: 5px;
}
.dialog-header {height: 70px;line-height: 70px;font-size: 20px;border-bottom: 1px solid #ccc;position: relative;
}
.dialog-header .close {position: absolute;right: 0px;top: 0px;cursor: pointer;
}
.dialog-content {height: 80px;font-size: 18px;padding: 15px 0;
}
.dialog-footer {display: flex;justify-content: flex-end;
}
.dialog-footer button {width: 65px;height: 35px;background-color: #ffffff;border: 1px solid #e1e3e9;cursor: pointer;outline: none;margin-left: 10px;border-radius: 3px;
}
.dialog-footer button:last-child {background-color: #007acc;color: #fff;
}
</style>

作用域插槽

  • 作用: 可以给插槽上绑定数据, 供将来使用组件时使用
  • 使用步骤:
    1. 给slot标签, 以添加属性的方式传值
    2. 所有属性都会被收集到一个对象中
    3. template中, 通过#插槽名="obj"接收
  • App.vue
    <template><div><MyTable :data="list"><!-- 3. 通过template #插槽名="变量名" 接收 --><template #default="obj"><button @click="del(obj.row.id)">删除</button></template></MyTable><MyTable :data="list2"><template #default="{ row }"><button @click="show(row)">查看</button></template></MyTable></div>
    </template><script>
    import MyTable from './components/MyTable.vue'
    export default {data () {return {list: [{ id: 1, name: '张小花', age: 18 },{ id: 2, name: '孙大明', age: 19 },{ id: 3, name: '刘德忠', age: 17 },],list2: [{ id: 1, name: '赵小云', age: 18 },{ id: 2, name: '刘蓓蓓', age: 19 },{ id: 3, name: '姜肖泰', age: 17 },]}},components: {MyTable},methods: {del(id){this.list = this.list.filter(item => item.id !== id)},show(row){// console.log(row)alert(`姓名: ${row.name}\n年纪: ${row.age}`)}}
    }
    </script>
    
  • MyTable.vue
    <template><table class="my-table"><thead><tr><th>序号</th><th>姓名</th><th>年纪</th><th>操作</th></tr></thead><tbody><tr v-for="(item, index) in data" :key="item.id"><td> {{index+1}} </td><td> {{item.name}} </td><td> {{item.age}} </td><td><!-- 1. 给slot标签, 添加属性的方式传值 --><slot :row="item" msg="test"></slot><!-- 2. 将所有的属性, 添加到一个对象中 --><!-- {row: { id: 2, name: '孙大明', age: 19 },msg: `test`}--></td></tr></tbody></table>
    </template><script>
    export default {props: {data: Array,},
    }
    </script><style scoped>
    .my-table {width: 450px;text-align: center;border: 1px solid #ccc;font-size: 24px;margin: 30px auto;
    }
    .my-table thead {background-color: #1f74ff;color: #fff;
    }
    .my-table thead th {font-weight: normal;
    }
    .my-table thead tr {line-height: 40px;
    }
    .my-table th,
    .my-table td {border-bottom: 1px solid #ccc;border-right: 1px solid #ccc;
    }
    .my-table td:last-child {border-right: none;
    }
    .my-table tr:last-child td {border-bottom: none;
    }
    .my-table button {width: 65px;height: 35px;font-size: 18px;border: 1px solid #ccc;outline: none;border-radius: 3px;cursor: pointer;background-color: #ffffff;margin-left: 5px;
    }
    </style>
    

案例 - 商品列表

my-tag 标签组件的封装
1. 创建组件 - 初始化
2. 实现功能2.1 双击显示, 并且自动聚焦v-if v-else @dblclick自动聚焦1. $nextTick => $refs 获取到dom, 进行focus获取焦点2. 封装v-focus指令2.2 失去焦点, 隐藏输入框@blur 操作 isEdit2.3 回显标签内容回显的标签信息是父组件传递过来的v-model实现功能(简化代码) v-model => :value 和 @input组件内部通过props接收, :value设置给输入框2.4 内容修改, 回车=> 修改标签信息@keyup.enter, 触发事件 $emit('input', e.target.value)
------------------------
my-table 表格组件的封装
1. 数据不能写死, 动态传递表格渲染的数据 props
2. 结构不能写死 - 多处结构自定义 [具名插槽]2.1 表头支持自定义2.2 主体支持自定义
  • App.vue
    <template><div class="table-case"><MyTable :data="goods"><template #head><th>编号</th><th>名称</th><th>图片</th><th width="100px">标签</th></template><template #body="{item, index}"><td> {{index+1}} </td><td> {{item.name}} </td><td><img :src="item.picture" /></td><td><!-- 标签组件 --><MyTag v-model="item.tag"></MyTag></td></template></MyTable></div>
    </template><script>
    import MyTag from './components/MyTag.vue'
    import MyTable from './components/MyTable.vue'
    export default {name: 'TableCase',components: {MyTag,MyTable},methods: {},data() {return {goods: [{id: 101,picture:'https://yanxuan-item.nosdn.127.net/f8c37ffa41ab1eb84bff499e1f6acfc7.jpg',name: '梨皮朱泥三绝清代小品壶经典款紫砂壶',tag: '茶具',},{id: 102,picture:'https://yanxuan-item.nosdn.127.net/221317c85274a188174352474b859d7b.jpg',name: '全防水HABU旋钮牛皮户外徒步鞋山宁泰抗菌',tag: '男鞋',},{id: 103,picture:'https://yanxuan-item.nosdn.127.net/cd4b840751ef4f7505c85004f0bebcb5.png',name: '毛茸茸小熊出没,儿童羊羔绒背心73-90cm',tag: '儿童服饰',},{id: 104,picture:'https://yanxuan-item.nosdn.127.net/56eb25a38d7a630e76a608a9360eec6b.jpg',name: '基础百搭,儿童套头针织毛衣1-9岁',tag: '儿童服饰',},],}},
    }
    </script><style lang="less" scoped>
    .table-case {width: 1000px;margin: 50px auto;img {width: 100px;height: 100px;object-fit: contain;vertical-align: middle;}
    }
    </style>
    
  • MyTable.vue
    <template><table class="my-table"><thead><tr><slot name="head"></slot></tr></thead><tbody><tr v-for="(item ,index) in data" :key="item.id"><slot name="body" :item="item" :index="index"></slot></tr></tbody></table>
    </template><script>
    export default {props: {data: {type:Array,required: true},},components: {}
    }
    </script><style  lang="less" scoped>
    .my-table {width: 100%;border-spacing: 0;img {width: 100px;height: 100px;object-fit: contain;vertical-align: middle;}th {background: #f5f5f5;border-bottom: 2px solid #069;}td {border-bottom: 1px dashed #ccc;}td,th {text-align: center;padding: 10px;transition: all 0.5s;&.red {color: red;}}.none {height: 100px;line-height: 100px;color: #999;}
    }
    </style>
    
  • MyTag.vue
    <template><div class="my-tag"><input v-if="isEdit"v-focus@blur="isEdit = false"ref="inp"class="input" type="text" :value="value"@keyup.enter="handleEnter"placeholder="输入标签"><div v-else@dblclick="handleClick"class="text">{{value}}</div></div>
    </template><script>
    export default {data () {return {isEdit: false}},props: {value: String},methods: {handleClick(){// 双击后, 切换到显示状态this.isEdit = true// // 由于Vue是异步dom更新, 所以要等dom更新完, 再获取焦点// this.$nextTick(() => {//   // 获取焦点//   this.$refs.inp.focus()// })},handleEnter(e){if(e.target.value.trim() === ''){return alert('标签内容不能为空')}// 子传父, 将回车时, [输入框的内容] 提交给父组件更新// 由于父组件是v-model, 触发事件, 需要触发input事件this.$emit('input', e.target.value)this.isEdit = false}}
    }
    </script><style lang="less" scoped>
    .my-tag {cursor: pointer;.input {appearance: none;outline: none;border: 1px solid #ccc;width: 100px;height: 40px;box-sizing: border-box;padding: 10px;color: #666;&::placeholder {color: #666;}}
    }
    </style>
    

路由入门

单页面应用程序

  • 单页面应用程序
    • 所有功能在一个html页面上实现
    • 优点: 按需更新性能高, 开发效率高, 用户体验好
    • 缺点: 学习成本, 首屏加载慢, 不利于SEO
    • 应用场景: 系统类/内部/文档类/移动端 网站

路由基本使用

路由的使用步骤 5 + 2
5个基础步骤
1. 下载 v3.6.5
2. 引入
3. 安装注册 Vue.use(Vue插件)
4. 创建路由对象
5. 注入到new Vue中,建立关联2个核心步骤
1. 建组件(views目录),配规则
2. 准备导航链接,配置路由出口(匹配的组件展示的位置) 
  • App.vue
    <template><div><div class="footer_wrap"><a href="#/find">发现音乐</a><a href="#/my">我的音乐</a><a href="#/friend">朋友</a></div><div class="top"><!-- 路由出口 → 匹配的组件所展示的位置 --><router-view></router-view></div></div>
    </template><script>
    export default {};
    </script><style>
    body {margin: 0;padding: 0;
    }
    .footer_wrap {position: relative;left: 0;top: 0;display: flex;width: 100%;text-align: center;background-color: #333;color: #ccc;
    }
    .footer_wrap a {flex: 1;text-decoration: none;padding: 20px 0;line-height: 20px;background-color: #333;color: #ccc;border: 1px solid black;
    }
    .footer_wrap a:hover {background-color: #555;
    }
    </style>
    
  • main.js
    import Vue from 'vue'
    import App from './App.vue'import Find from './views/Find'
    import My from './views/My'
    import Friend from './views/Friend'
    import VueRouter from 'vue-router'
    Vue.use(VueRouter) // VueRouter插件初始化const router = new VueRouter({// routes 路由规则们// route  一条路由规则 { path: 路径, component: 组件 }routes: [{ path: '/find', component: Find },{ path: '/my', component: My },{ path: '/friend', component: Friend },]
    })Vue.config.productionTip = falsenew Vue({render: h => h(App),router
    }).$mount('#app')

来源

黑马程序员. Vue2+Vue3基础入门到实战项目

相关文章:

Web前端-Vue2+Vue3基础入门到实战项目-Day5(自定义指令, 插槽, 案例商品列表, 路由入门)

自定义指令 基本使用 自定义指令: 自己定义的指令, 可以封装一些dom操作, 扩展额外功能全局注册// 1. 全局注册指令 Vue.directive(focus, {// inserted 会在 指令所在的元素, 被插入到页面中时触发inserted (el) {// el 就是指令所绑定的元素// console.log(el)el.focus()} …...

mysql json数据类型 相关函数

创建JSON文本的函数 1.JSON_ARRAY&#xff08;转换json数组&#xff09; 2.JSON_OBJECT&#xff08;转换json对象&#xff09; 3.JSON_QUOTE&#xff08;转义字符串&#xff09; 搜索JSON文本的函数 1.JSON_CONTAINS&#xff08;json当中是否包含指定value&#xff09; 2.J…...

如何实现前端实时通信(WebSocket、Socket.io等)?

聚沙成塔每天进步一点点 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 欢迎来到前端入门之旅&#xff01;感兴趣的可以订阅本专栏哦&#xff01;这个专栏是为那些对Web开发感兴趣、刚刚踏入前端领域的朋友们量身打造的。无论你是完全的新手还是有一些基础的开发…...

使用 SSSD 进行网络用户身份验证

文章目录 使用 SSSD 进行网络用户身份验证SSSD和Active Directory先决条件、假设和要求软件安装加域 SSSD配置自动创建HOME目录 检查和验证 Kerberos票证已知的问题参考 使用 SSSD 进行网络用户身份验证 SSSD 代表系统安全服务守护程序&#xff0c;它实际上是处理来自各种网络…...

紫光展锐携中国联通完成RedCap芯片V517孵化测试

近日&#xff0c;紫光展锐携手中国联通5G物联网OPENLAB开放实验室&#xff08;简称“OPENLAB实验室”&#xff09;共同完成RedCap芯片V517创新孵化&#xff0c;并实现在联通5G全频段3.5GHz、2.1GHz、900MHz下的端到端业务验证测试。 V517是一款基于紫光展锐5G成熟平台设计与研发…...

算法通关村第十一关青铜挑战——移位运算详解

大家好&#xff0c;我是怒码少年小码。 计算机到底是怎么处理数字的&#xff1f; 数字在计算机中的表示 机器数 一个数在计算机中的二进制表示形式&#xff0c;叫做这个数的机器数。 机器数是带符号的&#xff0c;在计算机用一个数的最高位存放符号&#xff0c;正数为0&am…...

2023年面试测试工程师一般问什么问题?

面试和项目一起&#xff0c;是自学路上的两大拦路虎。面试测试工程师一般会被问什么问题&#xff0c;总结下来一般是下面这4类&#xff1a; 1.做好自我介绍 2.项目相关问题 3.技术相关问题 4.人事相关问题 接下来&#xff0c;主要从以上四个方向分别展开介绍。为了让大家更有获…...

2023年中国汽车覆盖件模具竞争格局、市场规模及行业需求前景[图]

汽车覆盖件模具是汽车车身生产的重要工艺装备&#xff0c;其设计和制造时间约占汽车开发周期的 2/3&#xff0c;是汽车换型的重要制约因素之一。汽车覆盖件模具具有尺寸大、工作型面复杂、技术标准高等特点&#xff0c;属于技术密集型产品。汽车覆盖件模具按以其冲压的汽车覆盖…...

vue3项目运行报错import zhCn from “element-plus/lib/locale/lang/zh-cn“

解决办法 import zhCn from "element-plus/lib/locale/lang/zh-cn";修改为 import zhCn from "element-plus/dist/locale/zh-cn.mjs";...

读书笔记:Effective C++ 2.0 版,条款26(歧义)、条款27(禁止部分隐式生成的函数)

条款26: 当心潜在的歧义 即使cpp支持潜在二义性/歧义&#xff0c;也不要使用。 void f(int); void f(char); double d 6.02; f(d); //需要明确转换多继承充满了潜在二义性/歧义的可能。 class Base1 {public: int doIt();}; class Base2 {public: void doIt();}; class Deri…...

MySQL基本操作之数据库设计理论

1、数据的设计准则 1)糟糕的数据库设计表现在以下几个方面: 访问数据效率低下存在大量的数据冗余,浪费存储空间更新和检索数据时会出现许多问题2)良好的数据库设计表现在以下几方面: 访问效率高减少数据冗余,节省存储空间便于进一步扩展可以使应用程序的开发变得更容易…...

SpringBoot的日志系统(日志分组、文件输出、滚动归档)

[toc](目录) > SpringBoot3需要jdk17 # 1. 简介 1. Spring5及以后Spring自己实现了commons-logging&#xff0c;来作为内部的日志。日志的jar包是org.springframework:spring-jcl:6.0.10。查看org.apache.commons.logging.LogAdapter Java package org.apache.commons.log…...

一种基于HTTPS实现的Web账号登录Linux桌面系统的实现方案

问题由来 客户需求计划列入支持第三方帐号系统&#xff0c;包括Web账号。需求来源是用户想要用它们的帐号直接登录Linux Deepin操作系统。一个失败的实现方案是用户以较小的成本改造帐号管理系统发布HTTP服务&#xff0c;我们开发一个PAM模块与Web服务器交互&#xff0c;数据格…...

【Linux】psplash制作Linux开机动画

1. 下载psplash软件 下载psplash源码到ubuntu中&#xff1a; 下载地址&#xff1a;https://git.yoctoproject.org/psplash/commit/安装依赖环境 sudo apt-get install libgdk-pixbuf2.0-dev2. 准备图片 开机动画静态图片&#xff1a;psplash-poky.png开机动画进度条图片&…...

WMS透明仓库:实现仓储的全方位可视化与优化

一、WMS透明仓库的定义与特点 1. WMS透明仓库的定义&#xff1a;WMS透明仓库是一种基于信息技术的仓库管理系统&#xff0c;通过实时数据采集、分析和可视化&#xff0c;将仓库内外的物流流程、库存状态、人员活动等信息以透明的方式展示给相关利益方。 2. 实时数据采集&…...

软考系统架构师知识点集锦一:系统工程与信息系统基础

一、考情分析 二、考点精讲 2.1 软件开发方法 &#xff08;1&#xff09;结构化开发方法 用户至上&#xff0c;自顶向下,逐步分解(求解)&#xff0c;严格区分工作阶段&#xff0c;每阶段有任务与成果&#xff0c;强调系统开发过程的整体性和全局性&#xff0c;系统开发过程工…...

建筑模板常见的问题有哪些?

在建筑模板的使用过程中&#xff0c;常见的问题包括以下几个方面&#xff1a;1. 模板质量问题&#xff1a; - 模板破损或变形&#xff1a;模板可能在运输、安装或使用过程中受到损坏&#xff0c;如裂缝、断裂或变形。这可能导致模板的稳定性和承载能力下降。 - 模板尺寸不准确&…...

windows11录屏功能详解,记录你的精彩时刻

windows 11是微软最新推出的操作系统版本&#xff0c;拥有很多简单便捷的功能&#xff0c;包括内置的录屏工具&#xff0c;让用户可以轻松地录制屏幕内容。但是很多人不了解windows11录屏功能&#xff0c;本文将详细介绍windows 11录屏的三个方法&#xff0c;以及它们的优势和适…...

重入漏洞Victim

重入漏洞 顾名思义&#xff0c;重入漏洞可以简单理解为“重新进入的漏洞”。举个简单的例子&#xff0c;你往某个合约里存入了1个Ether&#xff0c;然后点击退款&#xff0c;按理来说只能退一个Ether&#xff0c;但是可以利用重入漏洞反复退款&#xff0c;把合约里的Ether掏空…...

wordpress数据库迁移Invalid default value for ‘comment_date‘

问题说明 最近在往新的电脑上迁移一个wordpress网站&#xff0c;在往新电脑上的mysql数据库中导入数据时&#xff0c;报错&#xff1a;1067 - Invalid default value for comment_date。 异常分析 这个错误的字面意思就是字段‘comment_date’的默认值是无效的&#xff0c;于…...

Cursor实现用excel数据填充word模版的方法

cursor主页&#xff1a;https://www.cursor.com/ 任务目标&#xff1a;把excel格式的数据里的单元格&#xff0c;按照某一个固定模版填充到word中 文章目录 注意事项逐步生成程序1. 确定格式2. 调试程序 注意事项 直接给一个excel文件和最终呈现的word文件的示例&#xff0c;…...

ssc377d修改flash分区大小

1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...

基于服务器使用 apt 安装、配置 Nginx

&#x1f9fe; 一、查看可安装的 Nginx 版本 首先&#xff0c;你可以运行以下命令查看可用版本&#xff1a; apt-cache madison nginx-core输出示例&#xff1a; nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...

CocosCreator 之 JavaScript/TypeScript和Java的相互交互

引擎版本&#xff1a; 3.8.1 语言&#xff1a; JavaScript/TypeScript、C、Java 环境&#xff1a;Window 参考&#xff1a;Java原生反射机制 您好&#xff0c;我是鹤九日&#xff01; 回顾 在上篇文章中&#xff1a;CocosCreator Android项目接入UnityAds 广告SDK。 我们简单讲…...

Spring AI 入门:Java 开发者的生成式 AI 实践之路

一、Spring AI 简介 在人工智能技术快速迭代的今天&#xff0c;Spring AI 作为 Spring 生态系统的新生力量&#xff0c;正在成为 Java 开发者拥抱生成式 AI 的最佳选择。该框架通过模块化设计实现了与主流 AI 服务&#xff08;如 OpenAI、Anthropic&#xff09;的无缝对接&…...

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别 直接训练提示词嵌入向量的核心区别 您提到的代码: prompt_embedding = initial_embedding.clone().requires_grad_(True) optimizer = torch.optim.Adam([prompt_embedding...

uniapp中使用aixos 报错

问题&#xff1a; 在uniapp中使用aixos&#xff0c;运行后报如下错误&#xff1a; AxiosError: There is no suitable adapter to dispatch the request since : - adapter xhr is not supported by the environment - adapter http is not available in the build 解决方案&…...

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决 问题背景 在一个基于 Spring Cloud Gateway WebFlux 构建的微服务项目中&#xff0c;新增了一个本地验证码接口 /code&#xff0c;使用函数式路由&#xff08;RouterFunction&#xff09;和 Hutool 的 Circle…...

在Ubuntu24上采用Wine打开SourceInsight

1. 安装wine sudo apt install wine 2. 安装32位库支持,SourceInsight是32位程序 sudo dpkg --add-architecture i386 sudo apt update sudo apt install wine32:i386 3. 验证安装 wine --version 4. 安装必要的字体和库(解决显示问题) sudo apt install fonts-wqy…...

[大语言模型]在个人电脑上部署ollama 并进行管理,最后配置AI程序开发助手.

ollama官网: 下载 https://ollama.com/ 安装 查看可以使用的模型 https://ollama.com/search 例如 https://ollama.com/library/deepseek-r1/tags # deepseek-r1:7bollama pull deepseek-r1:7b改token数量为409622 16384 ollama命令说明 ollama serve #&#xff1a…...