Vue.js 2 中没有定义 Howl 安装用法

问题描述

我安装了咆哮使用

*************************
******* FROM HTML *******
*************************
<div class="row" *ngIf="coupon">
   <div *ngIf="coupon.imageUrl" class="col-6" style="height: 70%; width: 40%;">
       <img src={{coupon.imageURL}} alt="..." style="width: 100%;height: 100%; ">
   </div>
    <div class="col-6" *ngIf="coupon.title && coupon.amount && coupon.category">
       <h1>{{coupon.title}}</h1>
       <h3>{{coupon.amount}}</h3>
       <h3>{{coupon.category}}</h3>
    </div>
</div>


***************************************
******* FROM service.ts file ********
***************************************
@Injectable()
export class CompanyService {

@Output() selectedCoupon = new EventEmitter<Coupon>()
coupon: Coupon

fetchCouponById(id: string) {
this.storagService.fetchCouponById(id)
  .subscribe(coupon => {
    if (coupon) {
       this.coupon = coupon
       this.onSelectCoupon()
    }
  })
}

onSelectCoupon() {
  this.selectedCoupon.emit(this.getCoupon())
}

getCoupon() {
  return this.coupon
}

This way you will be very sure that you have the object before you assign it anywhere. 

添加脚本

npm install -g  howler --save

即使在我添加的 index.html 文件中

require('howler');

它似乎可以工作,但是每次我的应用程序重新加载(我使用 npm run serve 来运行应用程序)时,我都会收到错误 Howl is not defined。然后我再次使用 npm 安装了 Howler 它可以工作,但在重新加载后再次停止工作。 所以基本上我需要一次又一次地重新安装howler。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)