onload事件支持的标签||onload设置有些标签无用

支持的标签:<body>, <frame>, <iframe>, <img>, <input type="image">, <link>, <script>, <style>
成功测试使用的标签:<body>, <style>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Login</title>
    <meta name="description" content="向客户们真实的呈现菜品,方便食客们的浏览">
    <meta name="author">


    <script type="text/javascript">

       var a=10

        function fun2() {
            console.log("我得到了交代你")
        }
       function fun() {
           document.getElementById("one").focus();
           console.log("onehaha")
       }
    </script>

</head>

<body onload="fun()" >

    <div class="box" style="margin: auto" >
        <h2>欢迎光临</h2>
<input id="one" type="text">
        <style onload="fun()"></style>

            <form action="login" method="post">

                <div class="input_box">
                    <p>账号&nbsp&nbsp<input id="userName" class="text" type="text" name="userName" placeholder="用户账号"   onfocus="fun2()"></p>
                </div>
                <div id="error_box1" calss="error"></div>
                <div class="input_box">
                    <p>密码&nbsp&nbsp<input id="password" class="text" style="color: #FFFFFF !important" style="color: #FFFFFF !important" class="text" type="password" name="password" placeholder="用户密码"></p>
                </div>

                <div class="input_box1">
                    <!-- <button type="submit" class="btn1" onclick="return validateCode()">登录</button> -->
                    <input type="submit" class="btn1" value="登录"  />
                </div>


            </form>
        </div>
    </div>
<script type="text/javascript">
    console.log("one")

</script>
</body>

</html>

import { _decorator, Component, Node, Input, EventTouch, Vec3, UITransform } from 'cc'; const { ccclass, property } = _decorator; @ccclass('yaogan') export class yaogan extends Component { @property(Node) stick: Node | null = null; @property max_R: number = 100; @property min_R: number = 20; public dir: Vec3 = new Vec3(0, 0, 0); onLoad() { if (this.stick) { this.stick.setPosition(new Vec3(0, 0, 0)); // 3.x使用Vec3坐标 // 触屏事件监听(3.x事件类型从Input获取) this.stick.on(Input.EventType.TOUCH_MOVE, this.on_stick_move, this); this.stick.on(Input.EventType.TOUCH_END, this.on_stick_end, this); this.stick.on(Input.EventType.TOUCH_CANCEL, this.on_stick_end, this); } } // 参数类型改为EventTouch on_stick_move(event: EventTouch) { if (!this.stick) return; const screenPos = event.touch.getLocation(); const uiTransform = this.node.getComponent(UITransform); if (!uiTransform) return; const pos = uiTransform.convertToNodeSpaceAR(new Vec3(screenPos.x, screenPos.y, 0)); //this.stick.setPosition(pos); const len: number = pos.length(); if ( len <= this.min_R ) { this.stick.setPosition(pos); return; } this.dir.x = pos.x / len; this.dir.y = pos.y / len; if ( len > this.max_R ){ pos.x = pos.x * this.max_R / len; pos.y = pos.y * this.max_R / len; } this.stick.setPosition(pos); } on_stick_end() { this.dir = new Vec3(0, 0, 0); if (this.stick) { this.stick.setPosition(new Vec3(0, 0, 0)); // 重置为Vec3原点 } } start() { // 保留空方法避免报错 } }为什么这段代码的检测鼠标移动行为放在onload而不是start里呢?
03-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值