2023/8/17总结

项目完善:

算法推荐

item-CF

算法推荐我主要写的是协同过滤算法,然后协同过滤算法分成俩种——

  • 基于用户的  user-CF 
  • 基于物品的    item-CF

因为害怕用户冷启动,和数据量的原因 我选择了 item-CF

主要思路是——根据用户的点赞列表,来找到点赞的相应的文章,通过这些文章去找到 相似度高的物品,然后进行推荐,如果数据不够,我会把浏览量最多的数据给顶上去。

下面是一个demo

数据库对应的数据:(点赞列表的数据)

 

因此可以看到会推荐三条数据。 

Vue

vue是是一个用于构建用户界面的渐进式框架

  • {{ }}是插值表达式
  • 使用的数据必须要存在
  • 支持的是表达式,不能写JavaScript的关键字如 if for
  • 不能在标签的属性里面使用

Vue指令

vue会根据不同的指令针对标签实现不同的功能

都是带有v-前缀的特殊标签属性

v-html  相当一innerHTML

v-show 控制元素显示隐藏   v-show后接的是表达式,为true是显示,例如:v-show=“true”  代表显示,false代表隐藏  本质上是通过css的dispaly来控制显示隐藏

v-if 控制元素显示隐藏(条件渲染) v-if也是接表达式,根据表达式的值来进行控制显示隐藏   这个是通过创建和删除元素来控制元素

v-else 后面不接表达式

v-else if 接表达式

v-on  这个是处理监听事件

v-on:事件名:="内联语句"

v-on:事件名称=“methods中的函数名称”

也可以直接写@事件名称=“”

v-bind:动态的设置html的标签属性,比如说src ur title  语法:v-bind:属性名称=“表达式”

可以直接写成   :属性=“表达式”

v-for:基于数据循坏,多次渲染整个元素  语法:v-for="{item,index} in 数组"

v-for里面的key的作用: 给元素添加的唯一标识,便于vue进行列表项的正确排序复用(如果没有设置key,那么删除元素,是把最后一个删除,并且把数据往前面移动)

key的值只能是字符串或者数字类型 

key的值必须是具有唯一性

v-model:  给表单元素使用 双向数据绑定  可以快速获取或者设置 表单元素内容  语法:v-model="变量"

案列:

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body
        {
            background: #eee;
        }
        .box
        {
            margin:50px auto;
            background: #fff;
            width: 500px;

        }
        .header
        {
            display: flex;
            margin:0 auto;
            box-sizing: border-box;
        }
        .header .inputTask
        {
            width: 70%;
            padding-left: 20px;
            margin-top:10px;
            margin-bottom: 10px;
            margin-left: 50px;
            height: 40px;
            box-sizing: border-box;
            border-bottom-left-radius: 20px;
            border-top-left-radius: 20px;
            border: 2px solid #609dbf;
            font-size: 16px;
            outline: none;
        }
        .header .addTask
        {
            width: 30%;
            margin-right: 50px;
            margin-top:10px;
            height: 40px;
            box-sizing: border-box;
            border: none;
            outline: none;
            color:#fff;
            font-size: 16px;
            background: #609dbf;
            border-bottom-right-radius: 20px;
            border-top-right-radius: 20px;
        }
        li
        {
            list-style: none;
        }
        .taskLi
        {
            margin-left: 20px;
            padding-bottom: 10px;
        }
        .taskLi
        {
            margin-top:20px;
            display: flex;
            margin-right:50px;
            border-bottom:2px solid #eee;
        }
        .taskLi .numLi
        {

        }
        .taskContent
        {
            flex:1;
            margin-left: 20px;
        }
        .delTask
        {
            display: none;
        }
        .taskLi:hover .delTask
        {
            display: block;
        }
        .total
        {
            display: flex;
            height: 50px;
            line-height: 40px;
            font-size: 14px;
            color:#666;
        }
        .totalNum
        {
            flex:1;
            margin-left: 55px;
        }
        .delAllTask
        {
            margin-right:50px;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="box">
        <div class="header">
            <input v-model="content" type="text" class="inputTask" placeholder="请输入任务">
            <button class="addTask" @click="addNewTask">添加任务</button>
        </div>
        <div class="footer">
            <ul>
                <li class="taskLi" v-for="(item,index) in list" :key="item.id">
                    <span class="numLi">{{ index + 1 }}</span>
                    <span class="taskContent">{{ item.name }}</span>
                    <button class="delTask" @click="delTask(item.id)">x</button>
                </li>

            </ul>
            <div class="total" v-show="list.length!=0">
                <span class="totalNum">合计&nbsp;&nbsp;:&nbsp;&nbsp;{{ list.length }}</span>
                <span class="delAllTask" @click="delAllTask">清空任务</span>
            </div>
        </div>
    </div>
</div>

<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            content:"",
            list:[
                { id:1,name:"开心" },
                { id:2,name:"吃饭" },
                { id:3,name:"看电影" },
                { id:4,name:"睡觉" }
            ]
        },
        methods:{
            addNewTask()
            {
                if(this.content.trim()==='')
                {
                    this.content='';
                    return 0;
                }
                this.list.unshift({id:+new Date(),name:this.content})
                this.content=""
            },
            delTask(id)
            {
                this.list=this.list.filter(item => item.id!==id)
            },
            delAllTask()
            {
                this.list=[]
            }
        }
    })
</script>
</body>
</html>

指令修饰符

通过  “ . ”  指明一些指令后缀,不同  后缀 封装了 不同的处理操作 

按键修饰符

@keyup.enter 就是键盘回车监听事件

v-model修饰符

@v-model.trim  去除首尾空格

事件修饰符号

@事件名.stop  阻止冒泡

@事件名.prevent  阻止默认行为

v-bind 对于1样式控制的增强

  • 操作class  语法   :class="对象/数组"

对象: 键就是类名  值是布尔值  如果值为true 有这个类,否则没有

数组:数组中所有的类,都会添加到盒子上,本质是一个class列表

案列:

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .nav
        {
            margin:20px auto;
            width: 600px;

            background: #eee;
        }
        .nav ul
        {
            display: flex;
            padding:0px;
        }
        li
        {
            list-style: none;
            padding:20px 20px;
            font-weight: bold;
        }
        .active
        {
            background: #609dbf;
            color:#fff;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="nav">
        <ul>
            <li v-for="(item,index) in list" @click="activeIndex=index" :class="{active:activeIndex==index}">{{ item }}</li>
        </ul>
    </div>
</div>

<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            activeIndex:0,
            list:[
                'lzy','helios','ares','king'
            ]
        },
        methods:{

        }
    })
</script>
</body>
</html>
  • 操作style

语法    :style="样式对象"

 案列:

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .bigBox
        {
            box-sizing: border-box;
            margin:40px auto;
            width: 400px;
            height: 40px;
            padding: 5px;
            background: black;
            border-radius: 20px;
        }
        .bigBox .smallBox
        {

            background: aqua;
            height: 30px;
            width: 390px;
            border-radius: 20px;
            transition: all 1s;
        }
        .percent
        {
            margin:0 auto;
            width: 60px;
        }
        .button
        {
            width: 250px;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="bigBox">
        <div class="smallBox" :style="{width:percent+'%'}">

        </div>

    </div>
    <div class="percent">{{percent}}%</div>
    <div class="button">
        <button @click="changePercent(0)">0%</button>
        <button @click="changePercent(25)">25%</button>
        <button @click="changePercent(50)">50%</button>
        <button @click="changePercent(75)">75%</button>
        <button @click="changePercent(100)">100%</button>
    </div>

</div>

<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            percent:0
        },
        methods:{
            changePercent(num)
            {
                this.percent=num;
            }
        }
    })
</script>
</body>
</html>

 计算属性

基于现有的数据,计算出来的新属性,依赖的数据变化,自动重新计算

语法:声明在computed配置项中,一个计算属性对应一个函数  使用起来和普通属性一样使用  也是{{  }}

案列:

 

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        table,th,td
        {
            border:1px solid black;
        }
        table
        {
            margin:20px auto;
        }
        th,td
        {
            padding: 5px 20px;
        }
        h3
        {
            width: 180px;
            margin: 0 auto;
        }
        h3 span
        {
            position: absolute;
            transform: translateX(-30px);
            transform: translateY(-10px);
            background: red;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            color: #fff;
        }
    </style>
</head>
<body>
<div id="app">
    <h3>lzy的购物清单 🛒<span>{{totalSize}}</span></h3>
    <table>
        <thead>
            <th>名称</th>
            <th>数量</th>
        </thead>
        <tbody>
            <tr v-for="(item,index) in list" :key="index">
                <td>{{item.name}}</td>
                <td>{{item.num}}</td>
            </tr>

            <tr>
                <td>总计</td>
                <td>{{totalSize}}</td>
            </tr>
        </tbody>
    </table>
</div>

<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            percent:0,
            list:[
                {name:"太阳",num:1},
                {name:"月亮",num:1},
                {name:"星星",num:7}
            ]
        },
        methods:{

        },
        computed:{
            totalSize()
            {
                return this.list.reduce((sum,item)=>sum+item.num,0);
            }
        }
    })
</script>
</body>
</html>

 计算属性和method的区别是 计算属性是由缓存的,method方法是会一直执行

计算属性默认的简写,是只能读取访问,不能修改的

如果需要修改,需要写计算属性的完整写法

computed:{

        计算属性名称:{

                get()

                {}

                set(修改的值)

                {代码逻辑}

}
}

案列

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #app
        {
            width: 300px;
            height: 300px;
            margin: 0 auto;
        }
        input
        {
            margin-left: 10px;
            width: 50px;
            margin-bottom: 20px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
<div id="app">
    姓:<input type="text" v-model="firstName"> + 名:<input type="text" v-model="lastName"> = <span>{{name}}</span>
    <br>
    <button @click="changeName">改名卡</button>
</div>

<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            firstName:'',
            lastName:''
        },
        methods:{
            changeName()
            {
                this.name='lzy'
            }
        },
        computed:{
            name:{
                get()
                {
                    return this.firstName+this.lastName;
                },
                set(value)
                {
                    this.firstName=value.slice(0,1);
                    this.lastName=value.slice(1)
                }
            }
        }
    })
</script>
</body>
</html>

 

案列:

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

        th
        {
            background: skyblue;
            height: 40px;
        }
        td
        {
            background: #eee;
            height: 40px;
        }
        th,td
        {
            padding: 0 20px;
        }
        table
        {
            margin: 0 auto;
        }
        .Fail
        {
            color:red;
        }
        .dealDel span
        {
            text-decoration-line: underline;
            font-style:italic;
            color:deepskyblue;
        }
        form
        {
            width: 300px;
            margin: 0 auto;
        }
        form input
        {
            margin-bottom: 10px;
            height: 30px;
            padding-left: 10px;

        }
        button
        {
            padding: 5px 20px;
            background: blue;
            outline: none;
            border: 0;
            color: #fff;

        }
    </style>
</head>
<body>
<div id="app">
    <table>
        <thead>
            <th>编号</th>
            <th>科目</th>
            <th>成绩</th>
            <th>操作</th>
        </thead>
        <tbody v-if="list.length > 0">
            <tr v-for="(item,index) in list">
                <td>{{ index+1 }}</td>
                <td>{{ item.subject }}</td>
                <td :class="{Fail:item.score<60}">{{item.score}}</td>
                <td class="dealDel">
                    <span @click="delOne(index)">删除</span>
                </td>
            </tr>
        </tbody>
        <tbody v-else>
            <tr>
                <td colspan="4" style="text-align: center;">
                    暂无数据
                </td>
            </tr>
        </tbody>
        <tr>
            <td colspan="4">
                总分:<span>{{ sum }}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                平均分:<span>{{ average }}</span>
            </td>
        </tr>
    </table>
    <br>
    <form action="">
        科目:<input type="text" v-model.trim="subject" placeholder="请输入科目">
        <br>
        成绩:<input type="text" v-model="score" placeholder="请输入成绩">
        <br>
        <button type="button" class="ensure" @click="addNew">确认</button>
    </form>
</div>

<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            list:[
                {subject:'语文',score:46},
                {subject:'数学',score:80},
                {subject:'英语',score:60}
            ],
            subject:'',
            score:''
        },
        methods:{
            delOne(i)
            {
                this.list=this.list.filter((item,index)=>index!=i);
            },
            addNew()
            {
                this.list.push({subject:this.subject,score:+this.score})
                this.score=''
                this.subject=''
            }
        },
        computed:{
            sum(){
                return this.list.reduce((sum,item)=>sum+=item.score,0);
            },
            average(){
                if(this.list.length>0)
                    return this.sum/this.list.length*100/100;
                else return 0
            }

        }
    })
</script>
</body>
</html>

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/92146.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

什么是JVM ?

目录 一、JVM 简介 1.1 JVM 发展史 1.Sun Classic VM 2.Exact VM 3.HotSpot VM 4.JRockit 5.J9 JVM 6.Taobao JVM&#xff08;国产研发&#xff09; 1.2 JVM 和《Java虚拟机规范》 二、 JVM 运行流程 JVM 执行流程 三、JVM 运行时数据区 3.1 堆&#xff08;线程共享…

86. 分隔链表(中等系列)

给你一个链表的头节点 head 和一个特定值 x &#xff0c;请你对链表进行分隔&#xff0c;使得所有 小于 x 的节点都出现在 大于或等于 x 的节点之前。 你应当 保留 两个分区中每个节点的初始相对位置。 示例 1&#xff1a; 输入&#xff1a;head [1,4,3,2,5,2], x 3 输出&…

wireshark 流量抓包例题重现

[TOC](这里写目录标题 wireshark抓包方法wireshark组成 wireshark例题 wireshark抓包方法 wireshark组成 wireshark的抓包组成为&#xff1a;分组列表、分组详情以及分组字节流。 上面这一栏想要显示&#xff0c;使用&#xff1a;CtrlF 我们先看一下最上侧的搜索栏可以使用的…

IDEA快速设置Services窗口

现在微服务下面会有很多SpringBoot服务&#xff0c;Services窗口方便我们管理各个SpringBoot服务&#xff0c;但有时IDEA打开项目后无法的看到Services窗口&#xff0c;以下步骤可以解决&#xff01;

系统架构设计高级技能 · 安全架构设计理论与实践

系列文章目录 系统架构设计高级技能 软件架构概念、架构风格、ABSD、架构复用、DSSA&#xff08;一&#xff09;【系统架构设计师】 系统架构设计高级技能 系统质量属性与架构评估&#xff08;二&#xff09;【系统架构设计师】 系统架构设计高级技能 软件可靠性分析与设计…

图床项目进度(二)——动态酷炫首页

前言&#xff1a; 前面的文章我不是说我简单copy了站友的一个登录页吗&#xff0c;我感觉还是太单调了&#xff0c;想加一个好看的背景。 但是我前端的水平哪里够啊&#xff0c;于是在网上找了找制作动态背景的插件。 效果如下图。 如何使用 这个插件是particles.js 安装…

[NLP]深入理解 Megatron-LM

一. 导读 NVIDIA Megatron-LM 是一个基于 PyTorch 的分布式训练框架&#xff0c;用来训练基于Transformer的大型语言模型。Megatron-LM 综合应用了数据并行&#xff08;Data Parallelism&#xff09;&#xff0c;张量并行&#xff08;Tensor Parallelism&#xff09;和流水线并…

使用代理突破浏览器IP限制

一、实验目的: 主要时了解代理服务器的概念&#xff0c;同时如何突破浏览器IP限制 二、预备知识&#xff1a; 代理服务器英文全称是Proxy Server&#xff0c;其功能就是代理网络用户去取得网络信息。形象的说&#xff1a;它是网络信息的中转站&#xff0c;特别是它具有一个cac…

4.15 TCP Keepalive 和 HTTP Keep-Alive 是一个东西吗?

目录 HTTP 的 Keep-Alive TCP 的 Keepalive 总结&#xff1a; HTTP的Keep-Alive&#xff0c;是应用层&#xff08;用户态&#xff09;实现的&#xff0c;称为HTTP长连接&#xff1b; TCP的Keepalive&#xff0c;是由TCP层&#xff08;内核态&#xff09;实现的&#xff0c;…

常见的移动端布局

流式布局&#xff08;百分比布局&#xff09; 使用百分比、相对单位&#xff08;如 em、rem&#xff09;等来设置元素的宽度&#xff0c;使页面元素根据视口大小的变化进行调整。这种方法可以实现基本的自适应效果&#xff0c;但可能在不同设备上显示不一致。 <!DOCTYPE ht…

深度学习5:长短期记忆网络 – Long short-term memory | LSTM

目录 什么是 LSTM&#xff1f; LSTM的核心思路 什么是 LSTM&#xff1f; 长短期记忆网络——通常被称为 LSTM&#xff0c;是一种特殊的RNN&#xff0c;能够学习长期依赖性。由 Hochreiter 和 Schmidhuber&#xff08;1997&#xff09;提出的&#xff0c;并且在接下来的工作中…

多维时序 | MATLAB实现BiTCN-BiGRU-Attention多变量时间序列预测

多维时序 | MATLAB实现SABO-CNN-GRU-Attention多变量时间序列预测 目录 多维时序 | MATLAB实现SABO-CNN-GRU-Attention多变量时间序列预测预测效果基本介绍模型描述程序设计参考资料 预测效果 基本介绍 多维时序 | MATLAB实现BiTCN-BiGRU-Attention多变量时间序列预测。 模型描…

python编程环境使用技巧-任务1-pip包管理工具

概要 任务1-pip包管理工具 pip是Python的包管理工具&#xff0c;它用于安装、升级和管理Python的第三方库以及它们的依赖关系。 在命令提示符或终端窗口中&#xff0c;可以使用以下常用的pip命令&#xff1a; 安装包&#xff1a;pip install package_name。它会自动下载并安…

OpenCV使用CMake和MinGW-w64的编译安装

OpenCV使用CMake和MinGW-w64的编译安装中的问题 问题&#xff1a;gcc: error: long: No such file or directory** C:\PROGRA~2\Dev-Cpp\MinGW64\bin\windres.exe: preprocessing failed. modules\core\CMakeFiles\opencv_core.dir\build.make:1420: recipe for target ‘modul…

个人记录:划分

原始数据展示 每五个大图移动一次所有的大图名称的小图片。 读取指定图片格式的图片名称&#xff0c;内置函数map执行,文件移动 图片01-17[:27] 图片17-70要改27为25 import os import shutil # source dataset/sat_train/ source_path "/mnt/sdb1/fenghaixia/dsm/da…

JDK1.8 安装教程(linux)

一、 检查当前系统是否已安装JDK 通过命令java –version 如果有出现如下图提示表示有安装&#xff0c;则无需再安装 二、 安装JDK 通过JDK官网https://www.oracle.com/上下载需要的JDK 版本&#xff0c;下载完成后上传到linux 系统上指定的文件夹下。&#xff08;可以用宝…

基于大语言模型知识问答应用落地实践 – 知识库构建(上)

01 背景介绍 随着大语言模型效果明显提升&#xff0c;其相关的应用不断涌现呈现出越来越火爆的趋势。其中一种比较被广泛关注的技术路线是大语言模型&#xff08;LLM&#xff09;知识召回&#xff08;Knowledge Retrieval&#xff09;的方式&#xff0c;在私域知识问答方面可以…

自然语言处理学习笔记(七)————字典树效率改进

目录 1. 首字散列其余二分的字典树 2.双数组字典树 3.AC自动机(多模式匹配) &#xff08;1&#xff09;goto表 &#xff08;2&#xff09;output表 &#xff08;3&#xff09;fail表 4.基于双数组字典树的AC自动机 字典树的数据结构在以上的切分算法中已经很快了&#x…

Nginx详解 第一部分:编译安装Nginx+Nginx模块

Part 1 一 、HTTP 和 Nginx1.1 套接字Socket1.2 URL1.2.1 定义1.2.1 URL和URN的区别1.2.3 URL组成 1.3 请求访问完整过程详解 二、I/O模型 处理高并发的时候用2.1 I/O模型简介2.2 多路复用I/O型2.3 异步I/O模型2.4 事件模型 select poll epoll 三、NGINX概述3.1 简介3.2 NGINX和…

ctfshow-web-红包题第六弹

0x00 前言 CTF 加解密合集CTF Web合集 0x01 题目 0x02 Write Up 首先跑一下字典&#xff0c;这里用的dirmap,可以看到有一个web.zip 下载下来之后发现是一个网站备份&#xff0c;备份的是check.php.bak 然后接着看&#xff0c;可以看到这里不太可能是sql注入&#xff0c;有…
最新文章