Git Product home page Git Product logo

cocoscreator-typescript-demo-qrcode's Introduction

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);
    }
}

cocoscreator-typescript-demo-qrcode's People

Contributors

nimohe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.