Category: Programming Language
-
Post Views: 16 1. There was an implementation before, which is to judge a specific record, whether it meets a certain complex nesting condition, and the code is implemented as follows 2. Now you need to query all records that meet this complex nesting condition, refer to:https://learnku.com/docs/laravel/6.x/queries/5171#2f5914, the code is implemented as follows 3. The final generated SQL is in…
-
Post Views: 32 1. Search in Githab: mocha, select the first one: mochajs/mocha, a simple, flexible and interesting JavaScript test framework for node.js and browsers. as shown in Figure 1 2. Click the link documentation to enterhttps://mochajs.org/ 3. Reference installation:https://mochajs.org/#installation, as a project development dependency, use npm to install, enter the project directory: npm install –save-dev mocha. as shown in…
-
Post Views: 17 1. Reference: In Refactoring: Improved Design of Existing Code (2nd Edition), build the test system – the writing of the sample code to be tested:https://www.shuijingwanwq.com/2023/01/28/7368/. The problem now is that multiple classes exist in the same file. Decided to split, each class forms a separate file. 2. Create a new class file /modules/producer.js, and migrate the class…
-
Post Views: 13 1. Now there is a string with the following contents 2. It is expected to batch replace the default in the string to basic 3. Refer to the str::replaceArray function to replace the given value in the string using the array order 4. Since there is only one element in the array $replace, only one default is…
-
Post Views: 17 1. A code to be tested. This code comes from a simple application that supports users to view and adjust production plans. Its (slightly rough) interface looks like the picture below. as shown in Figure 1 2. The final implementation of the example code is as follows, the productionplan.html file code of the entrance is as follows…
-
Post Views: 16 1. Report an error in PHP 7.4: Cannot RedeClare GetFirstSkuIndex(). Indicates that the function getFirstSkuIndex() has been defined. PHP does not support redefining declared functions. as shown in Figure 1 2. Reference:https://www.shuijingwanwq.com/2022/11/14/7149/, now because the same file is repeatedly introduced (re-introduced on business). This leads to the same function being duplicated. 3. View the code implementation of…
-
Post Views: 62 1. Generate a new module: blog. 2. By default, the module class will not load automatically. You can load your modules automatically using PSR-4. Edit composer.json. as shown in Figure 1 3. Tip: Don’t forget to run composer dump-autoload. as shown in Figure 2 4. Generate a given console command for the specified module. 5. Edit CreatePostCommand.php,…
-
Post Views: 19 1. UncaughtXError: Cannot use import statement outside a module (at statement.js:1:1). Reference: Refactoring: Improve the design of existing code (2nd edition). as shown in Figure 1 2. The code is implemented as follows, as shown in Figure 2 statement.html statement.js CreateStatementData.js 3. Reference:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Modules. JavaScript module. You need to put type=”module” into the script tag to declare that…
-
Post Views: 15 1. Reference: Run the .sh or shell script files in WSL in Windows 10. Since the .sh file is run, all environment configurations in the file must depend on the configuration items in Ubuntu. But the environment configuration in Ubuntu is not perfect. Decided to replace the shell script with php script 2. The code implementation of…