「云之家个性化开发」在表单中做一个按钮,要好看点的。点击后会跳转到www.baidu.com

535 阅读1分钟

此案例由@GzMax所提

运行效果

image.png

相关代码

cf.ready(function () {
    var button = document.createElement("button");
    button.className = "my-diy-button";
    button.textContent = "点我跳转百度";
    // 设置按钮样式 怎么好看怎么设置
    button.style.fontSize = "12px";
    button.style.backgroundColor = "orange";
    button.style.color = "#ffffff";
    button.style.borderRadius = "5px";
    button.style.padding = "5px 10px 5px 10px";
    button.style.height = "35px";
    button.style.width = "135px";
    button.style.alignSelf = "center";
    button.style.marginRight = "10px";
    // 设置点击行为 点击后跳转百度
    button.onclick = function () {
        window.open("https://www.baidu.com")
    }
    // 将创建的按钮插入标题控件后
    var success = cf.insertAfterContainer("_S_TITLE", button);
    if (success) {
        console.log("插入成功");
    }
});

说明 sdk支持原生js特性,创建按钮及设置按钮样式均可使用原生js完成

欢迎关注我的个人公众号「「小枫学幽默」」一起成长,一起分享生活!!

扫码关注我.png