1 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" /> |
P.S 这个方法在ios10以后无效 属性解释: 1.width width设置viewport的宽度,即iphone最初模拟PC浏览器的宽度,之后iphone会这个宽度展现的页面同比缩放到iphone屏幕上。设置width=device-width后就不会再进行缩放了,因为宽度正好和iphone的宽度相同(前提是没有设置缩放比例)。 2.minimum-scale和maximum-scale 控制用户允许设置的缩放比例的。 3.user-scalable 标识是否允许对页面进行缩放,取值有两个yes和no。设置为no则不允许进行页面缩放了。 4.initial-scale 设置用户最初看到页面时的缩放比例。 5.target-densitydpi Android 浏览器所需要的,因为 Android 硬件设备标准不一, 其中同样物理尺寸的屏幕,可能因为 dpi 的不同而具有不同的分辨率, Android 浏览器默认会缩放页面以便最好地呈现, 可惜和 Java 的垃圾回收一样,它很难做到"最好"。所以最好还是人工指定吧。 target-densitydpi 可以设定的值 device-dpi – 设备本身的像素 high-dpi -用高像素,中低像素屏幕适当缩小。 medium- 中等像素,高的屏幕放大,低的变小是默认值 low-dpi – 低像素,中高像素会适当变大。 from:http://t.zoukankan.com/bugs-p-3139811.html
View Details直接贴代码了: js调用
1 |
window.location.href = "tel:要拨打的电话号码"; |
a标签调用
1 2 3 4 5 |
<meta name="format-detection" content="telephone=yes"/> <a href="tel:要拨打的电话号码">点击打电话噢~</a> <a href="sms:要发短信的电话号码">发短信</a> |
from:https://blog.csdn.net/qq_42817227/article/details/102569519
View Details
1 2 |
head 里面加上: <meta name="format-detection" content="telephone=yes"/> |
1 2 |
需要拨打电话的地方: <a href="tel:400-0000-677">400-0000-688</a> |
1 2 |
发短信: <a href="sms:155********">发短信</a> |
点击页面上的电话号码 ,页面会调用手机的电话接口。 from:https://blog.csdn.net/baidu_39043816/article/details/108318327
View Details1. 创建一个文件包
2. npm init
3. 创建一个index.js 文件,并写入一些要实现的代码
4. npm install -g
5. npm link
6. npm login
7. npm publish
8. npm publish --registry=https://指定你要推送的包管理库
9. npm version patch // 更新版本
10. npm update gulp //可以把当前目录下node_modules子目录里边的对应模块更新至最新版本
11. npm unpublish npmhswcommonwei@1.0.2 // 可以撤销发布自己发布过的某个版本代码
微信小程序跳转外部链接 在开发小程序过程中,我们可能会有这样的需求,在小程序中打开H5或者外部链接 实现方法如下: 1、配置业务域名 小程序管理后台——开发(开发管理)——开发设置:新增业务域名 在这里将你需要的外部链接域名配置完之后,再下载校验文件(校验文件需要放到当前域名的根目录下) 2、不勾选 “不校验合法域名” 开发者工具进行 “不校验合法域名”配置 3、刷新项目配置 4、打开外部链接 以上操作均完成之后,便可以打开外部链接
1 |
<web-view src="{{src}}"> </web-view> |
情况1:外部链接没有带参数
1 2 3 4 5 6 |
//跳转前处理外部链接 handlePdf(e){ wx.navigateTo({ url: '../../outer/outer?src='+e.currentTarget.dataset.url+'&title=合同详情' }) }, |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//跳转后获取参数 data: { src:"", }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ src:options.src }) //设置当前标题 wx.setNavigationBarTitle({ title: options.title, }) }, |
情况2:外部链接带参数 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码 decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。
1 2 3 4 5 6 7 |
//跳转前处理外部链接 handlePdf(e){ let url="https://xxx/#/pdfInfo?url="+e.currentTarget.dataset.url wx.navigateTo({ url: '../../outer/outer?src='+encodeURIComponent(url)+'&title=合同详情' }) }, |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//跳转后获取参数 data: { src:"", }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ src:decodeURIComponent(options.src) }) //设置当前标题 wx.setNavigationBarTitle({ title: options.title, }) }, |
from:https://blog.csdn.net/weixin_44590591/article/details/124625562
View Details模式
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function obj1(name,age){ this.name=name; this.age=age; this.identity=function(){ var li=document.createElement("p"); var txt=document.createTextNode("白小纯"); li.appendChild(txt); document.body.appendChild(li); } } var person2=new obj1('白小纯',123); person2.identity(); alert(person2.name); |
工厂模式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function obj2(){ var lio=new Object(); //创建对象,对象属性赋值 lio.name='lio'; lio.attr='男'; lio.identity=function(){ var li=document.createElement("p"); var txt=document.createTextNode("白小纯"); li.appendChild(txt); document.body.appendChild(li); }; return lio; } var person=obj2(); //alert(person.name); |
原型模式
1 2 3 4 5 6 7 8 9 10 11 12 |
function obj3(){ //this.name='lio'; } obj3.prototype.name='lio'; obj3.prototype.identity= function (name) { alert("实际上是"+name); }; var person3=new obj3(); //检测是在实例中还是在原型中 alert(person3.hasOwnProperty("name")); alert(person3.hasOwnProperty("rename")); person3.identity('白小纯'); |
混合模式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function obj4(age) { this.age=age; this.rename='aaaa'; }; obj4.prototype={ constructor:obj4, name:'lio', age:123, identity: function (name) { alert(name+"实际上是白小纯"); } }; var person4=new obj4(18); alert(person4.hasOwnProperty("age"));//true person4.identity('lio'); |
from:https://blog.csdn.net/Amouzy/article/details/125974435
View Details1.path info传参 /articles/12 (查询id为12的文章,12是参数)
2.URL Query String传参 /articles?id=12
3.1.Body 传参 Content-Type: multipart/form-data
3.2.Body 传参 Content-Type: application/json,或其他自定义格式
4.Headers 传参 @RequestHeader
axios 会默认序列化 JavaScript 对象为 JSON。 如果想使用 application/x-www-form-urlencoded 格式,你可以使用下面的配置。 在浏览器环境,你可以使用 URLSearchParams API:
1 2 3 4 |
const params = new URLSearchParams(); params.append('param1', 'value1'); params.append('param2', 'value2'); axios.post('/foo', params); |
from:https://blog.csdn.net/init_yanxiao/article/details/113845330
View Details今天开发遇到个问题,服务器后端的Long类型数据,传到前端会出现精度丢失,如:164379764419858435,前端会变成164379764419858430。
在浏览器中做测试可知,这就是一个精度丢失的问题。
前端使用的axios来发起请求的,最开始以为是浏览器的问题,但是通过postman来请求是没问题,打开浏览器开发工具,在xhr下的response响应中也是没问题的,代表是请求成功后数据格式化出问题了,下面讲解下各种解决方案。
View Details