nimohe / cocosCreator-typeScript-demo-qrcode

cocosCreator项目:生成二维码组件的使用/ 使用typecript语言

Home Page:https://nimohe.github.io/cocosCreator-typeScript-demo-qrcode/build/web-mobile/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cocosCreator-typeScript-demo-qrcode

cocosCreator项目:生成二维码组件的使用/ 使用typecript语言

在线demo

说明

本Demo使用的js组件来自这里:

CQRCode.js

comp

project

项目说明

项目自身利用组件生成二维码。

  • cocosCreator版本:2.2.0
  • 使用语言:typeScript

Demo主要代码

HelloWorld.ts

const {ccclass, property} = cc._decorator;

@ccclass
export default class Helloworld extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    qrcodeNode:cc.Node;
    currHerf:string;

    // qrcodeComp:any;

    init(){
        cc.debug.setDisplayStats(false);
    }

    start () {
        // init logic
        this.label.string = this.text;
        this.qrcodeNode=this.node.getChildByName('qrcode') as cc.Node;
        cc.log(this.qrcodeNode);
        
        //获取当前页面所在的网址
        this.currHerf=window.location.href;

        this.changeQRCodeUI(this.currHerf);
    }

    /**
     * 改变二维码显示内容
     * @param str 
     */
    changeQRCodeUI(str:String){
        //写入数据
        this.qrcodeNode.getComponent('CQRCode').string=str;
    }

    /**
     * 输入框 内容发生变化
     * @param data 
     */
    editBoxChange(data:String){
        cc.log(data);
        this.changeQRCodeUI(data);
    }
}

About

cocosCreator项目:生成二维码组件的使用/ 使用typecript语言

https://nimohe.github.io/cocosCreator-typeScript-demo-qrcode/build/web-mobile/index.html


Languages

Language:JavaScript 82.8%Language:CSS 9.8%Language:HTML 5.4%Language:TypeScript 2.0%