1. Why can’t the value of this block be returned before it is instantiated? 2. Why can the value be returned only after instantiation? 3. The filter cannot be obtained directly from the prototype. Method? Why can’t it be used directly?
The Vue.filter method receives two parameters. The first parameter is the name of the filter, and the second parameter is the implementation of the filter. This static method is like telling me that there is a test filter, and the specific implementation is what you pass in. The second parameter, ok, I understand, I saved this filter globally, that’s all. If you want to call the test filter you passed in, you must instantiate it. During the instantiation process, the HTML template will be parsed. When you encounter {{1|test}} you wrote, OK, you know you need to call the test filter. , only then will the test filter be called and the value returned.
The Vue.filter method receives two parameters. The first parameter is the name of the filter, and the second parameter is the implementation of the filter. This static method is like telling me that there is a test filter, and the specific implementation is what you pass in. The second parameter, ok, I understand, I saved this filter globally, that’s all. If you want to call the test filter you passed in, you must instantiate it. During the instantiation process, the HTML template will be parsed. When you encounter {{1|test}} you wrote, OK, you know you need to call the test filter. , only then will the test filter be called and the value returned.