VUE中基础的小细节

1.MVVM简单说明
MVVM(Model-View-ViewModel), 源自于经典的 Model–View–Controller(MVC)模式。MVVM 的出现促进了 GUI (Graphical User Interface,简称 GUI,又称图形用户接口或者图形用户界面)前端开发与后端业务逻辑的分离,极大地提高了前端开发效率。MVVM 的核心是 ViewModel 层,它就像是一个中转站(value converter),负责转换 Model 中的数据对象来让数据变得更容易管理和使用,该层向上与视图层进行双向数据绑定,向下与 Model 层通过接口请求进行数据交互,起呈上启下作用。View 层展现的不是 Model 层的数据,而是 ViewModel 的数据,由 ViewModel 负责与 Model 层交互,这就完全解耦了 View 层和 Model 层,这个解耦是至关重要的,它是前后端分离方案实施的最重要一环。

在这里插入图片描述
在这里插入图片描述

ajax,axios,fetch的区别


vue 中的遍历引用类型(v-for)

对象遍历
在这里插入图片描述

在这里插入图片描述
数组遍历
在这里插入图片描述
在这里插入图片描述
mongo的基础指令
show dbs 获取你当前所有的数据库
use dataBase_name 创建数据库(没有-创建/存在-使用)
db 指查询你当前的数据库
db.stats() 查询你当前数据库的状态
db.dropDatabase() 删除你当前的数据库
db.help() 查询帮助
db.version() 获取你当前数据库的版本
db.database_name.help() 查询任意数据库的帮助
db.collection_name.find() 查询你当前集合内的信息

创建数据库之后查看没有出现music,
需要写入一个文档集合album;
insert插入 db.album.insertOne({‘title’:’xxxx’}),
查看采用db.album.find();
插入多条数据insertMany([{},{},{}])/insert
//db.album.insertMany([{},{}])
//db.album.insert([{},{}])

文档是一个键值(key-value)对(即BSON)。MongoDB 的文档不需要设置相同的字段,并且相同的字段不需要相同的数据类型,这与关系型数据库有很大的区别,也是 MongoDB 非常突出的特点。
一个简单的文档例子如下:
{“genres”: [“犯罪”,“剧情” ],“title”: “肖申克的救赎”}
Collection聚集集合操作
(1) 创建一个聚集集合
db.createCollection(“collName”, {size: 20, capped: true, max: 100});
db.collName.isCapped(); //判断集合是否为定容量
(2) 得到指定名称的聚集集合
db.getCollection(“account”);
(3) 得到当前db的所有聚集集合
db.getCollectionNames();
(4) 显示当前db所有聚集的状态
db.printCollectionStats();
(4) 删除集合
db.collectionname.drop();

(1) 添加
db.users.save({name: ‘zhangsan’, age: 25, sex: true});

添加多条数据db.users.save([{},{}])
(2) 修改
所有数据都添加一个artist
db.albums.updateMany({},{KaTeX parse error: Expected 'EOF', got '}' at position 18: …t:{artist:‘哈哈’}}̲) db.users.upda…set: {name: ‘changeName’}}, false, true);
相当于:update users set name = ‘changeName’ where age = 25;
1/修改的数据不存在—第一个参数false(不添加)true(添加)
2/数据有重复的---第二个参数true符合条件的数据均修改,false默认修改第一条数据
KaTeX parse error: Expected '}', got 'EOF' at end of input: …ame: 'Lisi'}, {inc: {age: 50}}, false, true);
相当于:update users set age = age + 50 where name = ‘Lisi’;
db.users.update({name: ‘Lisi’}, {$inc: {age: 50}, $set: {name: ‘hoho’}}, false, true);
相当于:update users set age = age + 50, name = ‘hoho’ where name = ‘Lisi’;
(3) 删除
db.users.remove({age: 132});

全部删除db.users.remove({});

1查询所有记录
db.userInfo.find();
相当于:select* from userInfo;
2查询去重后数据
db.userInfo.distinct(“name”);
相当于:select distict name from userInfo;

返回的是数组形式的去重的那一列
3查询age = 22的记录
db.userInfo.find({“age”: 22});
相当于: select * from userInfo where age = 22;

4查询age > 22的记录
db.userInfo.find({age: {KaTeX parse error: Expected 'EOF', got '}' at position 7: gt: 22}̲}); 相当于:select …lt: 22}});
相当于:select * from userInfo where age <22;

6查询age >= 25的记录
db.userInfo.find({age: {KaTeX parse error: Expected 'EOF', got '}' at position 8: gte: 25}̲}); 相当于:select …lte: 25}});
8查询age >= 23 并且 age <= 26
db.u8serInfo.find({age: {$gte: 23, $lte: 26}});
9查询name中包含 mongo的数据
db.userInfo.find({name: /mongo/});
//相当于%%
select * from userInfo where name like ‘%mongo%’;
10查询name中以mongo开头的
db.userInfo.find({name: /^mongo/});
select * from userInfo where name like ‘mongo%’;

11查询指定列name、age数据
db.userInfo.find({}, {name: 1, age: 1});
相当于:select name, age from userInfo;
12查询指定列name、age数据, age > 25
db.userInfo.find({age: {$gt: 25}}, {name: 1, age: 1});
相当于:select name, age from userInfo where age >25;
13按照年龄排序
升序:db.userInfo.find().sort({age: 1});
降序:db.userInfo.find().sort({age: -1});
14查询name = zhangsan, age = 22的数据
db.userInfo.find({name: ‘zhangsan’, age: 22});
相当于:select * from userInfo where name = ‘zhangsan’ and age = ’22’;
15查询前5条数据
db.userInfo.find().limit(5);
相当于:select top 5 * from userInfo;

16查询10条以后的数据
db.userInfo.find().skip(10);
相当于:select * from userInfo where id not in (
select top 10 * from userInfo);

17限制数据量/几条数据后
db.userInfo.find().limit(10).skip(5);
18or与 查询
db.userInfo.find({KaTeX parse error: Expected 'EOF', got '}' at position 27: …22}, {age: 25}]}̲); 相当于:select *…gte: 25}}).count();
相当于:select count(*) from userInfo where age >= 20;

21查询某一项的记录数目
db.userInfo.find({sex: {$exists: true}}).count();
相当于:select count(sex) from userInfo;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值