Tag Archives: window

Troubleshooting of typescript extended global window error

Using the custom attribute on the global window, typescript will report that the attribute does not exist,

console.log(window.foo) // ❌ Property ‘foo’ does not exist on type 'Window & typeof globalThis'.ts(2339)

The user-defined variable needs to be extended to the global window. You can add a type file or a normal. TS file in the project, as long as it can be found within the configuration scope of tsconfig.json.

type.d.ts

declare global {
  interface Window {
   	foo: string;
  }
}

If the following error occurs during type extension:

Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.ts(2669)

The following contents can be added to the type file to take the specified file as the template and eliminate the error.

+ export {};

declare global {
  interface Window {
    foo: string;
  }
}

Installing scrapy in window — solving the problem of error reporting

The system is win10 64 bit
Python is 3.5.2
install PIP install scrapy today    To install
Microsoft Visual C + + 14.0 is required

It is found that Microsoft Visual C + + 14.0 is actually installed on the computer, but it cannot be installed successfully anyway

Later, the solution was to use files to install

1. Download the scrapy installation file

2. Install this using the command PIP install wheel

3. Switch CMD to the directory where the scrapy file is located and install it by PIP install *********************************************************

4. You can use PIP install scrape to check whether the installation is successful

 

By the way, post a teaching article: introduction to slapy

Solution to the problem of bash: gulp: command not found after installing gulp in Windows system

Why are there a series of technical challenges behind “OMG buy it”>>>

When using the gulp server command, bash: gulp: command not found appears
first of all, when I saw this command, I doubted that my gulp was not installed properly. I executed it again NPM install - G gulp , but the command ran smoothly, and the result still appeared: bash: gulp: command not found
then I found the following article on the Internet
I feel that the direction to solve the problem is right. The command of gulp is invalid. It should be the configuration problem. Then I go to the global directory (C: program files/nodejsnode)_ modules/npm/node_ Modules) to see if my gulp package is installed, and it is not! My bag succeeded, but it was in the wrong place

1. Use the command to check: NPM config get prefix , and the following figure is obtained

looking at the location, it seems that it is the address that I configured when I used the lower version of node.. But now NPM has been integrated into node. I can’t find the configuration address myself. Anyway, there is absolutely no environment variable. Now I just want to correct the address and go to the new path I follow C:// program files/nodejs/node_ modules\npm

2. Use the command to modify the configuration

npm config set prefix C:\Program Files\nodejs\node_ As we all know, the file name of the program files in the middle is very hollow, which causes the command to be interrupted in this way. So I went to the configuration file to modify it manually (this is a simple and direct way). The file location is here C:// users/administrator (see the figure below)

3. Check the configuration of NPM again

as can be seen from the above figure, the configuration address now points to NPM in node, and then install gulp to see
running commands: NPM install - G gulp and gulp - V

whose view is not in the window hierarchy!

View hierarchy is also an important part of the responder chain. When we need to render the content in the window, the framework of the application will use it to detect the layer level of views and determine the part to be rendered, so as to avoid doing some useless work. This is very important.

Next, let’s look at the definition relationship of the three attributes of view in view hierarchy

1. Supervisor, parent view of view

2. Subviews, subviews of view

3. Window, including the window of view

The third window property is different between IOS and MAC.

In IOS, window is a view, but not in MAC.

In MAC, window has a single contentview, and all subviews are included in the contentview.

In IOS, window itself plays the role of content view, so all sub views are included in window.

In the process of development, there are some problems

1.ios attempt to present whose view is not in the window hierarchy

2.Warning: Attempt to present on whose view is not in the window hierarchy!

And so on. As long as there is a window hierarchy in it, it is caused by the poor understanding of viewhierarchy.

The above problem is that when the view of a controller is not added to the window, another controller is called present. This is equivalent to building a building. If the second floor is not finished, you can go to build the third floor directly. This is definitely not good.

the most direct solution to the above problem is to call present in the controller’s viewdidappearance. This ensures that the hierarchy of view hierarchy is not disordered.