{"id":16347280,"url":"https://github.com/hsiangleev/vue-puzzle","last_synced_at":"2025-11-09T02:30:29.208Z","repository":{"id":112080384,"uuid":"103802754","full_name":"hsiangleev/vue-puzzle","owner":"hsiangleev","description":"vue实现16格拼图","archived":false,"fork":false,"pushed_at":"2017-09-17T04:26:56.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T06:10:08.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hsiangleev.github.io/vue-puzzle/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hsiangleev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-17T04:24:46.000Z","updated_at":"2017-09-17T04:26:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"e858ed4e-4d5f-4e17-8408-e8965bc7e46b","html_url":"https://github.com/hsiangleev/vue-puzzle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiangleev%2Fvue-puzzle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiangleev%2Fvue-puzzle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiangleev%2Fvue-puzzle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiangleev%2Fvue-puzzle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hsiangleev","download_url":"https://codeload.github.com/hsiangleev/vue-puzzle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239565664,"owners_count":19660158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T00:41:01.521Z","updated_at":"2025-11-09T02:30:29.158Z","avatar_url":"https://github.com/hsiangleev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n### vue拼图\r\n [链接地址]( https://hsiangleev.github.io/vue-puzzle/ )\r\n\u003e1. 定义组件box\r\n\u003e 2. 使用slot在父组件插入button，调用子组件this.$children[0].randomNum()重新生成随机数组达到重新开始游戏的目的\r\n\u003e 3.  子组件中使用v-for生成li，再添加样式时使用 (!val) 给空值添加样式\r\n\u003e 4.  代码思路：\r\n\u003e \t* 定义两个数组，一个为完成后的，一个为打乱的\r\n\u003e \t打乱数组代码: \u003cbr\u003e\r\n\u003e ```javascript\r\n\u003e \tthis.randomArr.sort(function (a,b){\r\n\u003e \t  return Math.random()-0.5;\r\n\u003e \t})\r\n\u003e ```\r\n\u003e \t* 每次移动前获取点击的 value 值，和其上下左右的 value 值\r\n\u003e \t* 判断若四周有value值为空，则交换数组顺序\r\n\u003e \t交换数组顺序代码: \u003cbr\u003e\r\n\u003e \tthis.randomArr.splice(index,1,lNum);\u003cbr\u003e\r\n\u003e \tthis.randomArr.splice(index-1,1,cNum);\u003cbr\u003e\r\n\u003e \t* 每次移动后判断两个数组是否相等\r\n\u003e \t代码: \u003cbr\u003e\r\n\u003e ```javascript\r\n\u003e \tif(this.numArr.join(\" \")==this.randomArr.join(\" \")){\r\n\u003e \t\treturn true;\r\n\u003e \t}else{\r\n\u003e \t\treturn false;\r\n\u003e \t}\r\n\u003e ```\r\n\r\n***\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsiangleev%2Fvue-puzzle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhsiangleev%2Fvue-puzzle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsiangleev%2Fvue-puzzle/lists"}