Answers to the after-school exercises of WeChat applet development——Chapter 4 (homework version)

1. Fill in the blanks

1.  Components  are the basic unit of the view layer.

2. Only the   swiper-item    component can be placed inside the swiper.

3. Set the text content. Long press the optional attribute is   selectable   .   

4. The navigator component    distinguishes different jump functions by setting the  open-type  attribute.

5.    Set different image display modes through the mode  attribute of image.

2. Judgment questions

1. All components and properties are in lowercase. ( )

2. The video component is used to play audio. ( )

3. The audio component is used to play video. ( )

4. The canvas component is used to draw shapes. ( ) (Animation, games are also available)

5. Only when display: flex is set for the parent element, can the relevant properties of flex be used. ( )

3. Multiple Choice Questions

1. The following statement about the input component is wrong ( D ).

        A. You can set the disable of the input input box

        B. Used to control the input of single-line text content

        C. Add friendly prompt information to the input box through placeholder

        D. The type attribute of input has 3 valid types

2. The wrong description about the components is ( A ).

        A. All components are capitalized

        B. The component comes with some WeChat-style styles and functions

        C. Components are the basic unit of the view layer

        D. All components have basic properties

3. The wrong description about the form component is ( A ).

        A. The components in each form do not need to set the name attribute

        B. The form submits all components selected in the form

        C. The form component is used to submit the value in the form to the JS logic layer for processing

        D. The type in the button has two attributes, namely submit and reset

4. The following statement about the text component is correct (A ).

        A. The selectable attribute of text indicates whether the text is optional

        B. The space attribute of text, the effective value is emsp, which means the space size of Chinese characters

        C. The decode attribute of text, indicating whether to decode

        D. The text component supports the nesting of text and view

5. Which of the following statements about media components is correct ( A ).

        A. Media components include audio components, video components, and picture components

        B. The mode attribute of the image component has 12 display methods

        C, audio represents the video component

        D. The width and height of the video component cannot be set through WXSS

4. Short answer questions

1. Briefly describe how to use scroll-view to achieve horizontal scrolling of content

        (1) Create a  scroll-view component and set  scroll-x="true" properties to enable horizontal scrolling. You can set  scroll-y the property according to the actual situation to enable vertical scrolling, or enable horizontal and vertical scrolling at the same time.

        (2)  scroll-view Add content that needs to be scrolled in , you can use  view or other components to wrap the content. It should be noted that in order to achieve horizontal scrolling, the width of the content needs to be set to exceed the width of the view to trigger the scrolling effect.

        (3) According to actual needs, you can set  scroll-left and  scroll-top attribute to control the initial position and offset of scrolling. The values ​​of these properties can be dynamically set through the program code to realize the control and interaction of the scrolling effect.

        (4) When needed,  bindscroll events can be used to monitor the status and position of scrolling to implement related business logic, such as loading more data, updating scrolling indicators, etc.

2. Briefly describe how to get the value of the input input box

        (1) Create a  input component, set  bindinput properties, and bind the callback function of the input event.

        (2) In the callback function, use to get  event.detail.value the value of the input box. The value is of string type,

                    Indicates the text content in the current input box.

        (3) The value of the input box can be stored in the page data, or passed to other components through function parameters, to achieve

                     Data transfer and processing.

3. Please briefly describe which attribute in the input component can set the maximum length of the input text

        Components can be used  input to create text input boxes, and  maxlength attributes can be used to limit the maximum length of text entered.

  maxlength The attribute is a number type attribute, which is used to set the maximum number of characters allowed in the input box. When the text length in the input box reaches the maximum length, the user will not be able to enter any more characters. For example, if  maxlength the attribute is set to  10, only 10 characters can be entered in the input box

Guess you like

Origin blog.csdn.net/dazhanglao/article/details/130752375