海之蓝心 2020-02-22 23:56 采纳率: 33.3%
浏览 499
已结题

PIXI.TextInput 微信小游戏 引入失败

微信小游戏用的是pixi.js的框架,现在有需要要输入用户的姓名和手机号,找到了PIXI.TextInput ,但引入失败。

我是这么引入的:
import * as PIXI from './pixi.min.js'
import './js/base/PIXI.TextInput.js';

这是引入的报错,请问方法可以正常引入?或者有什么其他方法,表单输入。
VM1112 WAGame.js:3 Uncaught TypeError: Super expression must either be null or a function, not undefined
at _inherits (PIXI.TextInput.js:13)
at PIXI.TextInput.js? [sm]:1
at PIXI.TextInput.js? [sm]:1
at PIXI.TextInput.js? [sm]:1
at require (VM1112 WAGame.js:3)
at VM1112 WAGame.js:3
at VM1126 game.js:11
at require (VM1112 WAGame.js:3)
at :1:1
at HTMLScriptElement.scriptLoaded (:18:21)

    ---------------------
    自己解决了,要自己画,用小游戏提供的输入键盘接口,可能有些冗余,供参考。
    ---------------------

let userInput = new PIXI.Graphics();
userInput.lineStyle(4, 0x99CCFF, 1);
userInput.beginFill(0xffffff);
userInput.drawRoundedRect(0, 0, 300, 50, 30)
userInput.endFill();
app.stage.addChild(userInput);
userInput.y = 100 + 100 ;

let telephoneInput = new PIXI.Graphics();
telephoneInput.lineStyle(4, 0x99CCFF, 1);
telephoneInput.beginFill(0xffffff);
telephoneInput.drawRoundedRect(0, 0, 300, 50, 30)
telephoneInput.endFill();
app.stage.addChild(telephoneInput, userInput);
telephoneInput.y = 100 + 200;

const telephoneTxtStyle = new PIXI.TextStyle({
fontFamily: "Arial",
fontSize: 30,
fill: "#999",
letterSpacing: 0
});

let telephoneTxt = new PIXI.Text("", telephoneTxtStyle);
telephoneTxt.y = 105 + 200;
telephoneTxt.x = 10

const userTxtStyle = new PIXI.TextStyle({
fontFamily: "Arial",
fontSize: 30,
fill: "#999",
letterSpacing: 0
});

let userTxt = new PIXI.Text("", userTxtStyle);
userTxt.y = 105 + 100;
userTxt.x = 10

app.stage.addChild(telephoneTxt, userTxt);

telephoneInput.interactive = true;
let telephoneCount = 1;
let userSwitch = false;
telephoneInput.on('pointerdown', () => {
userSwitch = false
if (telephoneCount === 1) {
wx.showKeyboard({
multiple: false
})
telephoneCount++;
} else {
wx.showKeyboard({
multiple: false,
defaultValue: telephoneTxt.text
})
}
})

userInput.interactive = true;
let userCount = 1;
userInput.on('pointerdown', () => {
userSwitch = true;
if (userCount === 1) {
wx.showKeyboard({
multiple: false
})
userCount++;
} else {
wx.showKeyboard({
multiple: false,
defaultValue: userTxt.text
})
}
})

wx.onKeyboardInput((o) => {
if (userSwitch) {
userTxt.text = o.value;
} else {
telephoneTxt.text = o.value;
}
})

  • 写回答

2条回答 默认 最新

  • dabocaiqq 2020-02-23 13:05
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型