角度添加代码片段显示错误

时间:2018-08-10 12:46:24

标签: angular

我试图将此代码添加到app.component.ts文件的我的有角项目中,但它显示了一个错误

var options = {
  facebook: "facebook_id", // Facebook page ID
  whatsapp: "+XXXXXXXXX", // WhatsApp number
  call_to_action: "Message us", // Call to action
  button_color: "#008000", // Color of button
  position: "left", // Position may be 'right' or 'left'
  order: "facebook,whatsapp", // Order of buttons
};
var proto = document.location.protocol,
  host = "whatshelp.io",
  url = proto + "//static." + host;
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = url + '/widget-send-button/js/init.js';
s.onload = function() {
  WhWidgetSendButton.init(host, proto, options);
};
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);

错误:

Error

1 个答案:

答案 0 :(得分:0)

WhWidgetSendButton中声明app.component.ts

我已在 Stackblitz

上创建了一个演示
declare var WhWidgetSendButton;
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
export class AppComponent {

}