时间:2019-05-07 来源:小程序工厂
黄***:
黄***:
你好,这个demo代码能否提供一下
textarea设置auto-focus不能拉起键盘
灰***:
这个问题是我在项目开发的时候碰到的,不是demo诶
灰***:
有类似问题的demo我也有一个,怎么给你呢?
黄***:
可以精简个demo给我,麻烦直接贴上来
内嵌网页+微信小程序开发
灰***: //index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
screenWH: [],
isBottomShow:true
},
//事件处理函数
bindViewTap: function() {
},
getScreenWH: function (callback) {
try {
var res = wx.getSystemInfoSync();
var wh = this.data.screenWH;
wh.push(res.windowWidth);
wh.push(res.windowHeight);
if (callback){
callback();
}
} catch (e) {
}
},
onLoad: function () {
var that = this;
that.getScreenWH(function(){
that.draw();
});
},
draw:function(){
var that = this;
var context = wx.createCanvasContext("canvas");//底层画布
context.setFontSize(30);
context.save();
//居中前绘制
context.setFillStyle('black');
context.fillText('Hello', 30, 30);
context.restore();
context.save();
//居中绘制
context.setTextAlign('center');//居中
context.setFillStyle('blue');
context.fillText('Hello2', 30, 100);
// context.setTextAlign('left');//恢复左对齐可以正常显示
context.restore();
context.save();
//居中后绘制
context.setFillStyle('red');
context.fillText('Hello3', 30, 60);
context.restore();
context.draw(false, function(){
wx.canvasToTempFilePath({
canvasId: 'canvas',
success: function (res) {
setTimeout(function () {
//隐藏底层画布
that.setData({
isBottomShow: false
});
var ctx = wx.createCanvasContext("canvas_above");//覆盖在上层的画布
ctx.drawImage(res.tempFilePath, 0, 0, that.data.screenWH[0], that.data.screenWH[1]);
ctx.draw();
}, 5 * 1000);
}
});
});
}
})
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
.container {
height: 100%;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
page{
width: 100%;
height: 100%;
}
.canvas{
width: 100%;
height: 100%;
padding: 0;
margin: 0;
position: absolute;
left: 0;
top: 0;
}
.above{
z-index: 10000;
}
全部的demo代码,麻烦看一下,辛苦~
黄***:
已经重现了,我们定位一下,会尽快修复
灰***:
嗯嗯,辛苦,等你们的好消息~