angular引入jquery并测试弹窗
时间: 2023-04-04 22:04:55 浏览: 121
可以使用以下代码将 jQuery 引入 Angular 项目中:
1. 在 index.html 文件中添加以下代码:
```html
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
```
2. 在组件中使用以下代码测试弹窗:
```typescript
import { Component } from '@angular/core';
declare var $: any;
@Component({
selector: 'app-root',
template: `
<button (click)="showPopup()">Show Popup</button>
`
})
export class AppComponent {
showPopup() {
// 使用 jQuery 弹窗插件
$.alert({
title: 'Hello!',
content: 'This is a popup.',
});
}
}
```
这样就可以在 Angular 项目中使用 jQuery 弹窗了。
阅读全文
相关推荐
















