Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'antd-mobile' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
deleteSongList(id){
Modal.alert('确认删除歌单?', '歌单内的歌曲会一并删除', [
{ text: '取消', onPress: () => console.log('cancel') },
{ text: '确认', onPress: () => {
this.props.delCollectSongList(id,this.state.userId)
} },
])
}
/* onSelect = (opt) => {
render(){
const Item = List.Item
const Brief = Item.Brief
const userid = this.props.user._id
const userinfo = this.props.chat.users
// console.log(this.props)
const msgGroup = {}
this.props.chat.chatmsg.forEach(v=>{
msgGroup[v.chatid] = msgGroup[v.chatid] || []
msgGroup[v.chatid].push(v)
})
const chatList = Object.values(msgGroup).sort((a,b)=>{
const a_last = this.getLast(a).create_time
const b_last = this.getLast(b).create_time
return b_last - a_last
})
func.then((res) => {
this.setState({loading: false});
Toast.success(formatMessage({ id: 'SEND.SUCCESS' }), 3, () => onCancel(), true);
// PopupAPI.setPushMessage({
// title:`-${amount}${selectedToken.abbr} ${formatMessage({id:'NOTIFICATIONS.TITLE'})}`,
// message:formatMessage({id:'NOTIFICATIONS.MESSAGE'}),
// hash:res
// });
}).catch(error => {
Toast.fail(JSON.stringify(error), 3, () => {
constructor(props) {
super(props)
this.props = props
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => { return r1 !== r2 }
})
this._footer = this._footer.bind(this)
this._row = this._row.bind(this)
this._onRefresh = this._onRefresh.bind(this)
this.ds = ds
this.state = {
_data: [],
// refresh: false
}
}
/**
* Created by Administrator on 2017/8/10.
*/
import React, { Component } from 'react'
import { List, Button } from 'antd-mobile'
import { connect } from 'react-redux'
import { saveListData } from '../../redux/actions'
import './listItem.less'
const Item = List.Item
class ListItems extends Component {
// 确认参会
ensurePart = () => {
this.props.ensurePart()
}
// 取消参会
cancelPart = () => {
this.props.cancelPart()
}
//签到
sign = () => {
this.props.sign()
handleSubmit = e => {
e.preventDefault();
const { username, password } = this.state.form;
const { dispatch } = this.props;
if (!username) {
Toast.show('请输入用户名');
return;
}
if (!password) {
Toast.show('请输入密码');
return;
}
Toast.loading('登录中...', 0);
// ajax
AjaxLogin(this.state.form)
.then(res => {
if (res && res.code === 1) {
let user = res.data;
// dispatch
dispatch(setUser(user));
// set cookie
let expiresTime = new Date(new Date().getTime() + 2 * 60 * 60 * 1000); //2h
handleSubmit = e => {
e.preventDefault();
const { username, password } = this.state.form;
const { dispatch } = this.props;
if (!username) {
Toast.show('请输入用户名');
return;
}
if (!password) {
Toast.show('请输入密码');
return;
}
Toast.loading('登录中...', 0);
// ajax
AjaxLogin(this.state.form)
.then(res => {
if (res && res.code === 1) {
let user = res.data;
// dispatch
dispatch(setUser(user));
// set cookie
let expiresTime = new Date(new Date().getTime() + 2 * 60 * 60 * 1000); //2h
Cookie.set('token', user.token, { expires: expiresTime });
Cookie.set('username', user.username);
Toast.info('登录成功', 1, this.props.history.goBack());
}
/* tslint:disable:jsx-no-multiline-js */
import { List, Radio, WhiteSpace } from 'antd-mobile';
import React from 'react';
import { Text, View } from 'react-native';
const RadioItem = Radio.RadioItem;
export default class BasicRadioExample extends React.Component {
state = {
part1Value: 1,
part2Value: 1,
};
render() {
return (
get validatePassed() {
// forbid gd
if (this.state.school_id === 1) {
Toast.fail('请输入正确的密码', 1)
return false
}
if (this.state.school_id === -1) {
Toast.offline('请选择你的学校噢~', 1)
return false
}
if (!this.state.account) {
Toast.offline('请输入学号噢~', 1)
return false
}
if (!this.state.password) {
Toast.offline('请输入密码噢~', 1)
return false
import React from 'react'
import List from '../List';
import { Tabs } from 'antd-mobile';
import { connect } from 'react-redux';
import { topics } from '../../store/actions';
const TabPane = Tabs.TabPane;
const tabs = {
'全部': 'all',
'精华': 'good',
'分享': 'share',
'问答': 'ask',
'招聘': 'job',
// '测试': 'dev'
};
class MyTabs extends React.Component {
changeTab = (value) => {
const { loading, refresh, changeTab } = this.props;
if (loading || refresh) return;
changeTab(value);