海之蓝心 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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入