拖拽
- 1、下载 npm i sortablejs angular-sortablejs
// 在命令行中输入 npm i sortablejs angular-sortablejs 下载
- 2、在app.mudule.ts中引入 ```javascript /* 拖拽插件 / import {SortablejsModule} from ‘angular-sortablejs’;
@NgModule({ //… imports: [ //… SortablejsModule.forRoot({animation: 150}), ], })
- **3、在页面/组件中使用**
```javascript
// html文件
<div [sortablejs]="comnboList" [sortablejsOptions]="sortOptions" class="list">
<div *ngFor='let item of comnboList;index as idx' nz-row nzType="flex" nzJustify="space-between" nzAlign="middle" nzGutter="8" class="combo-item">
<div nz-col class="src" nzSpan="6">
<img [src]="item.src" alt="" class="">
</div>
<div nz-col class="" nzSpan="10">
{{ item.auth }}
</div>
<div nz-col class="delete" nzSpan="4">
删除
</div>
</div>
</div>
// ts文件
import {SortablejsOptions} from 'angular-sortablejs';
// ...
public comnboList:object[] = [
{id:0,src:'1',auth:'王小波',order:0},
{id:1,src:'2',auth:'王小波-1',order:1},
{id:2,src:'3',auth:'王小波-2',order:2},
{id:3,src:'4',auth:'王小波-3',order:3},
{id:4,src:'5',auth:'王小波-4',order:4},
{id:5,src:'6',auth:'王小波-5',order:5},
{id:6,src:'1',auth:'王小波-6',order:6},
]
sortOptions: SortablejsOptions = {
group: 'comnbo',
onStart: (/**Event*/ evt) => {
console.log(evt);
},
onEnd: (/**Event*/ evt) => {
console.log(evt);
}
//...
};
上传
// 下载命令: npm install @uppy/core @uppy/dashboard @uppy/instagram @uppy/tus
import Uppy from '@uppy/core'
import Dashboard from '@uppy/dashboard'
import Instagram from '@uppy/instagram'
import Tus from '@uppy/tus'
Uppy()
.use(Dashboard, {
trigger: '#select-files',
showProgressDetails: true
})
.use(Instagram, {
target: Dashboard,
serverUrl: 'https://companion.uppy.io'
})
.use(Tus, { endpoint: 'https://master.tus.io/files/' })
.on('complete', (result) => {
console.log('Upload result:', result)
})