Becavalier / Book-DISO-WebAssembly

A book related repository which name is 《深入浅出 WebAssembly》
MIT License
72 stars 17 forks source link

第七章7.3.4 touch事件Demo和7.4.2事件Demo无法运行 #10

Open leisurele opened 5 years ago

leisurele commented 5 years ago

emcc版本号:(emscripten 1.38.30 : 1.38.30) 错误: 使用书上提示命令

# 7.3.4
 emcc html5_touch.cc --bind -s WASM=1 -o html5_touch.html
# 7.4.2
emcc sdl.cc -s WASM=1 -s FORCE_FILESYSTEM=1 -s USE_SDL=2 --preload-file hello_sdl.bmp -o sdl.html

行html时提示如下错误,

sdl.html:1246 Rules for selecting event targets in HTML5 API are changing: instead of using document.getElementById() that only can refer to elements by their DOM ID, new event target selection mechanism uses the more flexible function document.querySelector() that can look up element names, classes, and complex CSS selectors. Build with -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 to change to the new lookup rules. See https://github.com/emscripten-core/emscripten/pull/7977 for more details.

在https://github.com/emscripten-core/emscripten/pull/7977 查看需要添加-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1参数,添加后,会报\

sdl.html:1246 exception thrown: SyntaxError: Failed to execute 'querySelector' on 'Document': The provided selector is empty.,Error: Failed to execute 'querySelector' on 'Document': The provided selector is empty. at findEventTarget (http://localhost:8081/sdl/sdl.js:6853:101) at findCanvasEventTarget (http://localhost:8081/sdl/sdl.js:6859:56) at _emscripten_set_canvas_element_size (http://localhost:8081/sdl/sdl.js:6879:20) at wasm-function[738]:271 at wasm-function[1025]:3063 at wasm-function[280]:128 at wasm-function[283]:49 at Object.Module._main (http://localhost:8081/sdl/sdl.js:9790:33) at Object.callMain (http://localhost:8081/sdl/sdl.js:10086:30) at doRun (http://localhost:8081/sdl/sdl.js:10144:60) printErr @ sdl.html:1246 callMain @ sdl.js:10106 doRun @ sdl.js:10144 (anonymous) @ sdl.js:10155 setTimeout (async) run @ sdl.js:10151 runCaller @ sdl.js:10063 removeRunDependency @ sdl.js:1694 receiveInstance @ sdl.js:1788 receiveInstantiatedSource @ sdl.js:1815 Promise.then (async) createWasm @ sdl.js:1831 Module.asm @ sdl.js:1864 (anonymous) @ sdl.js:9661 17:11:54.241 sdl.js:218 Uncaught DOMException: Failed to execute 'querySelector' on 'Document': The provided selector is empty. at findEventTarget (http://localhost:8081/sdl/sdl.js:6853:101) at findCanvasEventTarget (http://localhost:8081/sdl/sdl.js:6859:56) at _emscripten_set_canvas_element_size (http://localhost:8081/sdl/sdl.js:6879:20) at wasm-function[738]:271 at wasm-function[1025]:3063 at wasm-function[280]:128 at wasm-function[283]:49 at Object.Module._main (http://localhost:8081/sdl/sdl.js:9790:33) at Object.callMain (http://localhost:8081/sdl/sdl.js:10086:30) at doRun (http://localhost:8081/sdl/sdl.js:10144:60)

暂时没找到可解决的方案