Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Dian SnippetsNew to Visual Studio Code? Get it now.
Dian Snippets

Dian Snippets

chuanxing

|
23 installs
| (1) | Free
小电代码片段
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

小电开发代码片段

taro-react

import { useEffect } from 'react'
import { useDidHide, useDidShow } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './index.less'

interface IProps {
  
}

export default function Component(props: IProps) {
  useEffect(() => {
    console.log('> load')
    return () => {
      console.log('> unload')
    }
  }, [])

  useDidShow(() => {
    console.log('> show')
  })
  useDidHide(() => {
    console.log('> hide')
  })

  return (
    <View>
      <Text>Component</Text>
    </View>
  )
}

react

import { useEffect } from 'react'

interface IProps {
  
}

export default function Component(props: IProps) {
  useEffect(() => {
    console.log('> load')
    return () => {
      console.log('> unload')
    }
  }, [])

  return (
    <div>
      <div>Component</div>
    </div>
  )
}

useState

const [state, setstate] = useState(initialState)

useEffect

useEffect(() => {
  
}, [])

use-ref

useImperativeHandle(ref, () => ({
  
}))

columns

const columns = [{
  title: '',
  dataIndex: '',
}, {
  title: '操作',
  render (_: any, record: any) {
    return (
      <div>
        <a onClick={() => {}}>编辑</a>
        <Popconfirm placement="top" title="确定要执行本操作?" onConfirm={() => {}}>
          <a>删除</a>
        </Popconfirm>
      </div>
    )
  },
}]

for

for (let index = 0; index < array.length; index++) {
  const item = array[index]
  
}

for-of

for (const iterator of object) {
  
}

for-in

for (const key in object) {
  if (Object.hasOwnProperty.call(object, key)) {
    const item = object[key]
    
  }
}

foreach

array.forEach(item => {
  
})

//

/**
 * [description]
 * @param  {[type]} param [description]
 * @return {[type]} [description]
 */
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft