0%

在 Linux 环境通过 npm 全局安装 pm2 后,运行 pm2 命令却显示没有找到该命令:-bash: pm2: command not found。上网查找资料发现,这是因为没有创建软连接导致的。

阅读全文 »

在 nginx 服务器上准备调试 Nuxt 项目时,打开浏览器却发生了下图的情形。可以看到,样式发生明显错乱,图片资源也没有加载出来。而我在本地代码调试时,显示效果是正常的。在反复确认本地代码和服务端上的代码并无二致后,查看报错信息发现引入的 css 文件、js 文件以及图片资源都没有加载出来。

阅读全文 »

一、ts 类型

1. 基本类型:string, number, boolean

Note: The type names String, Number, and Boolean (starting with capital letters) are legal, but refer to some special built-in types that will very rarely appear in your code. Always use string, number, or boolean for types.

阅读全文 »

typeof 转换类型

typeof 转换类型结果
{}object
[]object
nullobject
undefinedundefined
NaNnumber
0number
trueboolean
‘ ‘string

number 转换类型

Number 转换结果
Number({})NaN
Number([])0
Number(‘’)0
Number(null)0
Number(undefined)NaN
Number(NaN)NaN
阅读全文 »

AJAX

(一)AJAX 概述

AJAX(Asynchronous JavaScript And XML,异步的 JavaScript 和 XML),是一种实现无页面刷新获取服务器数据的混合技术。它能够使浏览器在不刷新页面的情况下获取服务器响应,这将大大提升互联网用户的使用体验,同时,由于 AJAX 请求获取的是数据而不是 HTML 文档,因此它也节省了网络带宽,让互联网用户的网络冲浪体验变得更加顺畅。

阅读全文 »

一、JavaScript 是动态弱类型语言

1. 弱类型语言

JavaScript 是一门弱类型语言。语言类型的强弱,业界并没有提供权威的概念进行区分。但大体而言,强类型语言会有更严格的类型约束,不允许已声明类型的变量出现隐式的类型转换。而弱类型语言几乎不受限制,这种变量类型的不确定性可能会给代码带来隐患。

阅读全文 »

1. 字符串截取

slice(start, end)
1
2
3
4
5
6
var str = 'abcdefg' 
str.slice(1) // 'bcdefg'
str.slice(-1) // 'g'
str.slice(1, 3) // 'bc'
str.slice(1, -1) // 'bcdef'
str.slice(3, 1) // ''
阅读全文 »

1. 判断是否为对象

1
2
Object.prototype.toString.call({}) === '[object Object]'
Object.prototype.toString.call([]) === '[object Array]'
阅读全文 »

Math is a built-in object that has properties and methods for mathematical constants and functions. It’s not a function object.

Math works with the Number type. It doesn’t work with BigInt.

阅读全文 »