Fxiaoke Developer Manual Fxiaoke Developer Manual
  • APL Development Manual
  • PWC Development Manual
  • OpenAPI Documentation
  • Custom Components (PC)
  • Custom Components (Mini Program)
  • Custom Plugins (PC)
  • Custom Plugins (Mini Program)
  • Third-party Integration Plugins (H5)
  • API (PC)
  • API (Mini Program)
  • Fx DevTools
Update Log
  • 简体中文
  • English
  • Custom Components (PC)
  • Custom Components (Mini Program)
  • Custom Plugins (PC)
  • Custom Plugins (Mini Program)
  • Third-party Integration Plugins (H5)
  • API (PC)
  • API (Mini Program)
  • Fx DevTools
Update Log
  • 简体中文
  • English
  • Getting Started

  • Components

  • Examples

  • FAQ

    • Custom Component's Data Property
    • How to Reuse Custom Components
    • How to Compatible with PC and Mobile
      • How to Debug Custom Components
      • iframe Embedding Issues
    Table of Contents

    How to Support Both PC and Mobile

    # How to Support Both PC and Mobile

    Due to differences in viewport sizes between PC and mobile devices, UI and UX variations exist. Therefore, when developing custom components, it's often necessary to accommodate both device types.

    # Prerequisites

    Before learning how to debug custom components, you should know:

    1. Custom components are developed based on the JavaScript ecosystem
    2. Custom components are developed based on the Vue ecosystem

    # Compatibility Approaches

    # Develop Two Separate Components for PC and Mobile

    This approach is highly recommended.

    PC Version

    <template>
    	<div>
        	This is the PC version
      	</div>
    </template>
    <script>
        export default {
            props: ['data']
        }
    </script>
    

    Mobile Version

    <template>
    	<div>
        	This is the mobile version
      	</div>
    </template>
    <script>
        export default {
            props: ['data']
        }
    </script>
    

    senior-how-pcmobile-1

    Finally, use the corresponding custom component in layouts for different platforms.

    # Develop a Single Component with Runtime Adaptation
    <template>
    	<div :class="{'wrap-pc': isPC, 'wrap-mobile': !isPC}">
        	{{isPC ? 'This is the PC version' : 'This is the mobile version'}}
      	</div>
    </template>
    <script>
        var UA = typeof window !== 'undefined' && window.navigator && window.navigator.userAgent.toLowerCase()
        var isAndroid = (UA && UA.indexOf('android') > 0);
        var isIOS = (UA && /iphone|iPhone|ipad|ipod|ios/.test(UA));
        var isPC = !isAndroid && !isIOS;
        export default {
            props: ['data'],
            data() {
                return {
                    isPC: isPC
                }
            }
        }
    </script>
    

    Finally, use the same custom component across different platform layouts.

    How to Reuse Custom Components
    How to Debug Custom Components

    ← How to Reuse Custom Components How to Debug Custom Components→

    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式